public async Task <Guid> Create(Models.Inscrits insc) { try { var context = CreateContext(); var created = new Data.Inscrits { Id = insc.Id, Nom = insc.Nom, Prenom = insc.Prenom, CptFacebook = insc.CptFacebook, AdEmail = insc.AdEmail, AdresseId = insc.AdresseId, DdN = insc.DdN, ReglementOK = insc.ReglementOK, EstPJ = insc.EstPJ, EstPNJ = insc.EstPNJ, EstOrga = insc.EstOrga, }; var enr = await context ._Inscrits .AddAsync(created); await context.SaveChangesAsync(); return(enr.Entity.Id); } catch (DbUpdateException e) { Console.WriteLine(e.Message); return(insc.Id); } }
public async Task Update(Models.Inscrits insc) { try { var context = CreateContext(); var toUpdate = await context._Inscrits.FindAsync(insc.Id); if (toUpdate != null) { toUpdate.Id = insc.Id; toUpdate.Nom = insc.Nom; toUpdate.Prenom = insc.Prenom; toUpdate.CptFacebook = insc.CptFacebook; toUpdate.AdEmail = insc.AdEmail; toUpdate.AdresseId = insc.AdresseId; toUpdate.DdN = insc.DdN; toUpdate.ReglementOK = insc.ReglementOK; toUpdate.EstPJ = insc.EstPJ; toUpdate.EstPNJ = insc.EstPNJ; toUpdate.EstOrga = insc.EstOrga; await context.SaveChangesAsync(); } } catch (DbUpdateException e) { Console.WriteLine(e.Message); } }
public async Task Delete(Models.Inscrits insc) { try { var context = CreateContext(); var toDelete = await context._Inscrits.FindAsync(insc.Id); if (toDelete != null) { context._Inscrits.Remove(toDelete); await context.SaveChangesAsync(); } } catch (DbUpdateException e) { Console.WriteLine(e.Message); } }