public async Task <Adult> UpdateAdultAsync(Adult adult) { try { Adult toUpdate = await ctx.Adult.FirstAsync(t => t.Id == adult.Id); toUpdate.Age = adult.Age; toUpdate.Height = adult.Height; toUpdate.HairColor = adult.HairColor; toUpdate.Sex = adult.Sex; toUpdate.Weight = adult.Weight; toUpdate.EyeColor = adult.EyeColor; toUpdate.FirstName = adult.FirstName; toUpdate.LastName = adult.LastName; toUpdate.JobTitle = adult.JobTitle; ctx.Update(toUpdate); await ctx.SaveChangesAsync(); return(toUpdate); } catch (Exception e) { throw e; } }
public async Task <Adult> UpdateAdultAsync(Adult adult) { try { Adult toUpdate = await ctx.Adults.FirstAsync(t => t.Id == adult.Id); ctx.Update(toUpdate); await ctx.SaveChangesAsync(); return(toUpdate); } catch (Exception e) { throw new Exception($"Did not find adult with given id: {adult.Id}"); } }