public async Task <Guid> Create(Models.CalendriersMultiples cale) { try { var context = CreateContext(); var created = new Data.CalendriersMultiples { CalendrierId = cale.CalendrierId, PaysContreeId = cale.PaysContreeId, Id = cale.Id, }; var enr = await context ._CalendriersMultiples .AddAsync(created); await context.SaveChangesAsync(); return(enr.Entity.Id); } catch (DbUpdateException e) { Console.WriteLine(e.Message); return(cale.Id); } }
public async Task Delete(Models.CalendriersMultiples cale) { try { var context = CreateContext(); var toDelete = await context._CalendriersMultiples.FindAsync(cale.Id); if (toDelete != null) { context._CalendriersMultiples.Remove(toDelete); await context.SaveChangesAsync(); } } catch (DbUpdateException e) { Console.WriteLine(e.Message); } }
public async Task Update(Models.CalendriersMultiples cale) { try { var context = CreateContext(); var toUpdate = await context._CalendriersMultiples.FindAsync(cale.Id); if (toUpdate != null) { toUpdate.CalendrierId = cale.CalendrierId; toUpdate.PaysContreeId = cale.PaysContreeId; toUpdate.Id = cale.Id; await context.SaveChangesAsync(); } } catch (DbUpdateException e) { Console.WriteLine(e.Message); } }