Beispiel #1
0
        public async Task <Adult> UpdateAsync(Adult adult)
        {
            using (AdultDBContext dbContext = new AdultDBContext())
            {
                dbContext.Adults.Update(adult);
                await dbContext.SaveChangesAsync();

                return(adult);
            }
        }
Beispiel #2
0
        public async Task <Adult> AddAdultAsync(Adult adult)
        {
            using (AdultDBContext context = new AdultDBContext())
            {
                context.Adults.Add(adult);
                await context.SaveChangesAsync();

                return(adult);
            }
        }
Beispiel #3
0
 public async Task RemoveAdultAsync(int id)
 {
     using (AdultDBContext context = new AdultDBContext())
     {
         Adult adult = context.Adults.Where(a => a.Id == id).
                       Include(a => a.JobTitle).First();
         context.Adults.Remove(adult);
         context.Jobs.Remove(adult.JobTitle);
         await context.SaveChangesAsync();
     }
 }