public GeneralResponse EditCenter(IEnumerable <EditCenterRequest> requests, Guid ModifiedEmployeeID) { GeneralResponse response = new GeneralResponse(); foreach (var request in requests) { Center center = new Center(); center = _centerRepository.FindBy(request.ID); if (center != null) { try { center.ModifiedDate = PersianDateTime.Now; center.ModifiedEmployee = _employeeRepository.FindBy(ModifiedEmployeeID); if (request.CenterName != null) { center.CenterName = request.CenterName; } if (request.Note != null) { center.Note = request.Note; } #region RowVersion if (center.RowVersion != request.RowVersion) { response.ErrorMessages.Add("EditConcurrencyKey"); return(response); } else { center.RowVersion += 1; } #endregion #region Validation if (center.GetBrokenRules().Count() > 0) { foreach (BusinessRule businessRule in center.GetBrokenRules()) { response.ErrorMessages.Add(businessRule.Rule); } return(response); } #endregion _centerRepository.Save(center); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); return(response); } } else { response.ErrorMessages.Add("NoItemToEditKey"); return(response); } } try { _uow.Commit(); } catch (Exception ex) { response.ErrorMessages.Add(ex.Message); if (ex.InnerException != null) { response.ErrorMessages.Add(ex.InnerException.Message); } } return(response); }