예제 #1
0
 public void EditAdult(Adult updatedAdult)
 {
     foreach (var adult in Adults)
     {
         if (adult.Id == updatedAdult.Id)
         {
             adult.Update(updatedAdult);
         }
     }
 }
예제 #2
0
        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));
        }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
 public void Update(Adult toUpdate)
 {
     jobTitle = toUpdate.jobTitle;
     base.Update(toUpdate);
 }
예제 #6
0
파일: Model.cs 프로젝트: PaulBujor/dnp-asg1
 public async Task AddAdult(Adult adult)
 {
     adults.Add(adult);
     file.SaveChanges();
 }
예제 #7
0
 public void Update(Adult toUpdate)
 {
     JobTitle    = toUpdate.JobTitle;
     IsCompleted = toUpdate.IsCompleted;
     base.Update(toUpdate);
 }