Ejemplo n.º 1
0
 public void EditAdult(Adult updatedAdult)
 {
     foreach (var adult in Adults)
     {
         if (adult.Id == updatedAdult.Id)
         {
             adult.Update(updatedAdult);
         }
     }
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 5
0
 public void Update(Adult toUpdate)
 {
     jobTitle = toUpdate.jobTitle;
     base.Update(toUpdate);
 }
Ejemplo n.º 6
0
 public async Task AddAdult(Adult adult)
 {
     adults.Add(adult);
     file.SaveChanges();
 }
Ejemplo n.º 7
0
 public void Update(Adult toUpdate)
 {
     JobTitle    = toUpdate.JobTitle;
     IsCompleted = toUpdate.IsCompleted;
     base.Update(toUpdate);
 }