Exemple #1
0
 public async Task SaveFamilyItem(Family entity, int id)
 {
     if (entity.Id == default)
     {
         entity.EmployeeId            = id;
         _context.Entry(entity).State = EntityState.Added;
     }
     else
     {
         entity.EmployeeId            = id;
         _context.Entry(entity).State = EntityState.Modified;
     }
     await _context.SaveChangesAsync();
 }
Exemple #2
0
        public async Task <int> SaveEmployeeItem(Employee entity)
        {
            if (entity.Id == default)
            {
                _context.Entry(entity).State = EntityState.Added;
            }
            else
            {
                _context.Entry(entity).State = EntityState.Modified;
            }
            _context.SaveChanges();

            return(_context.Employees.OrderByDescending(x => x.Id).FirstOrDefaultAsync().Result.Id);
        }