|
@ -21,10 +21,13 @@ namespace CoviDok.Data.MySQL |
|
|
return c; |
|
|
return c; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async Task SetCase(int id, CaseStatus status) |
|
|
public async Task SetCase(int id, CaseStatus status, Update message) |
|
|
{ |
|
|
{ |
|
|
Case c = await context.Cases.FindAsync(id); |
|
|
Case c = await context.Cases.FindAsync(id); |
|
|
|
|
|
message.CaseID = c.Id; |
|
|
|
|
|
context.Updates.Add(message); |
|
|
c.CaseStatus = status; |
|
|
c.CaseStatus = status; |
|
|
|
|
|
c.Updates.Add(message); |
|
|
await context.SaveChangesAsync(); |
|
|
await context.SaveChangesAsync(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -35,7 +38,17 @@ namespace CoviDok.Data.MySQL |
|
|
|
|
|
|
|
|
public Update GetUpadte(int id) |
|
|
public Update GetUpadte(int id) |
|
|
{ |
|
|
{ |
|
|
return (from u in context.Updates where u.Id == id select u).First(); |
|
|
Update update = (from u in context.Updates where u.Id == id select u).First(); |
|
|
|
|
|
if (update != null) |
|
|
|
|
|
{ |
|
|
|
|
|
update.Images = (from i in context.Images where i.UpdateID == update.Id select i.ImageID).ToList(); |
|
|
|
|
|
} |
|
|
|
|
|
return update; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool IsAssistantOfDoctor(int id, int doctorID) |
|
|
|
|
|
{ |
|
|
|
|
|
return context.Assistants.Any( (a) => a.Id == id && a.DoctorId == doctorID); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async Task<List<Case>> Filter(CaseFilter filter) |
|
|
public async Task<List<Case>> Filter(CaseFilter filter) |
|
@ -81,6 +94,15 @@ namespace CoviDok.Data.MySQL |
|
|
string[] forbidden = { "Updates" }; |
|
|
string[] forbidden = { "Updates" }; |
|
|
PropertyCopier<Case>.Copy(Case, c, forbidden); |
|
|
PropertyCopier<Case>.Copy(Case, c, forbidden); |
|
|
context.Updates.Add(update); |
|
|
context.Updates.Add(update); |
|
|
|
|
|
foreach (string ImageID in update.Images) |
|
|
|
|
|
{ |
|
|
|
|
|
Image image = new Image |
|
|
|
|
|
{ |
|
|
|
|
|
UpdateID = update.Id, |
|
|
|
|
|
ImageID = ImageID |
|
|
|
|
|
}; |
|
|
|
|
|
context.Images.Add(image); |
|
|
|
|
|
} |
|
|
update.CreatedDate = DateTime.Now; |
|
|
update.CreatedDate = DateTime.Now; |
|
|
c.Updates.Add(update); |
|
|
c.Updates.Add(update); |
|
|
await context.SaveChangesAsync(); |
|
|
await context.SaveChangesAsync(); |
|
|