public int Create(EmployeePass item) { _db.EmployeePasses.Add(item); _db.SaveChanges(); return(item.Id); }
public void Update(EmployeePass item) { var entity = _db.EmployeePasses.Include(x => x.Employee).Where(x => x.Id == item.Id).AsQueryable().FirstOrDefault(); if (entity == null) { throw new ArgumentNullException(nameof(entity)); } _db.Entry(entity).State = EntityState.Modified; _db.Entry(entity).CurrentValues.SetValues(item); _db.Entry(entity.Employee).CurrentValues.SetValues(item.Employee); _db.SaveChanges(); }