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