Browse Source

Change Update method on MySql handlers

master
Daniel Gyulai 4 years ago
parent
commit
893fc8d3b5
  1. 3
      CoviDok/Data/MySQL/MySqlAssistantHandler.cs
  2. 3
      CoviDok/Data/MySQL/MySqlCaseHandler.cs
  3. 3
      CoviDok/Data/MySQL/MySqlChildHandler.cs
  4. 3
      CoviDok/Data/MySQL/MySqlDoctorHandler.cs
  5. 3
      CoviDok/Data/MySQL/MySqlParentHandler.cs

3
CoviDok/Data/MySQL/MySqlAssistantHandler.cs

@ -20,8 +20,7 @@ namespace CoviDok.Data.MySQL
public async Task SetAssistant(int id, Assistant value)
{
Assistant ast = new Assistant { Id = id };
context.Attach(ast);
Assistant ast = await context.Assistants.FindAsync(id);
context.Entry(ast).State = EntityState.Modified;
PropertyCopier<Assistant>.Copy(value, ast);
await context.SaveChangesAsync();

3
CoviDok/Data/MySQL/MySqlCaseHandler.cs

@ -76,8 +76,7 @@ namespace CoviDok.Data.MySQL
public async Task UpdateCase(int id, Case Case, Update update)
{
Case c = new Case { Id = id };
context.Attach(c);
Case c = await context.Cases.FindAsync(id);
context.Entry(c).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
string[] forbidden = { "Updates" };
PropertyCopier<Case>.Copy(Case, c, forbidden);

3
CoviDok/Data/MySQL/MySqlChildHandler.cs

@ -30,8 +30,7 @@ namespace CoviDok.Data.MySQL
public async Task UpdateChild(int id, Child newData)
{
Child child = new Child { Id = id };
context.Attach(child);
Child child = await context.Children.FindAsync(id);
context.Entry(child).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
PropertyCopier<Child>.Copy(newData, child);
await context.SaveChangesAsync();

3
CoviDok/Data/MySQL/MySqlDoctorHandler.cs

@ -52,8 +52,7 @@ namespace CoviDok.Data.MySQL
public async Task UpdateDoctor(int id, Doctor value)
{
Doctor doctor = new Doctor { Id = id };
context.Attach(doctor);
Doctor doctor = await context.Doctors.FindAsync(id);
context.Entry(doctor).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
PropertyCopier<Doctor>.Copy(value, doctor);
await context.SaveChangesAsync();

3
CoviDok/Data/MySQL/MySqlParentHandler.cs

@ -29,8 +29,7 @@ namespace CoviDok.Data.MySQL
public async Task UpdateParent(int id, Parent value)
{
Parent Parent = new Parent { Id = id };
context.Attach(Parent);
Parent Parent = await context.Parents.FindAsync(id);
context.Entry(Parent).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
PropertyCopier<Parent>.Copy(value, Parent);
await context.SaveChangesAsync();

Loading…
Cancel
Save