public void EditAdult(Adult updatedAdult) { foreach (var adult in Adults) { if (adult.Id == updatedAdult.Id) { adult.Update(updatedAdult); } } }
public async Task <ActionResult <Models.Adult> > AddAnAdult(Models.Adult adult) { using (FamilyDBContext familyDbContext = new FamilyDBContext()) { int id = familyDbContext.Adults.OrderBy(adult1 => adult1.Id).Last().Id; adult.Id = id + 1; familyDbContext.Adults.Add(adult); await familyDbContext.SaveChangesAsync(); } return(adult); }
public override bool Equals(object obj) { if (this == obj) { return(true); } Adult helper = obj as Adult; return(AdultJob.Equals(helper.AdultJob) && Persona.Age == helper.Persona.Age && Persona.Height == helper.Persona.Height && Persona.Id == helper.Persona.Id && Persona.Sex.Equals(helper.Persona.Sex) && Persona.Weight.Equals(helper.Persona.Weight) && Persona.EyeColor.Equals(helper.Persona.EyeColor) && Persona.FirstName.Equals(helper.Persona.FirstName) && Persona.HairColor.Equals(helper.Persona.HairColor) && Persona.LastName.Equals(helper.Persona.LastName)); }
public async Task <bool> RemoveAnAdult(int id) { using (FamilyDBContext familyDbContext = new FamilyDBContext()) { try { Models.Adult adult = await familyDbContext.Adults.FirstAsync(a => a.Id == id); Job job = await familyDbContext.Jobs.FirstAsync(j => j.Id == adult.JobTitle.Id); familyDbContext.Adults.Remove(adult); familyDbContext.Remove(job); await familyDbContext.SaveChangesAsync(); return(true); } catch (Exception e) { return(false); } } }
public void Update(Adult toUpdate) { jobTitle = toUpdate.jobTitle; base.Update(toUpdate); }
public async Task AddAdult(Adult adult) { adults.Add(adult); file.SaveChanges(); }
public void Update(Adult toUpdate) { JobTitle = toUpdate.JobTitle; IsCompleted = toUpdate.IsCompleted; base.Update(toUpdate); }