public Operation <StaffModel> UpdateStaff(StaffModel model) { return(System.Operation.Create(() => { //model.Validate(); var isExist = _context.Staffs.Find(model.StaffId); if (isExist == null) { throw new Exception("staff does not exist"); } var entity = model.Edit(isExist, model); _context.Entry(entity); _context.SaveChanges(); return model; })); }