public ActionResult Edit(EditServiceFunctionViewModel model) { if (_appUserContext.Current.CurrentCustomer == null || _appUserContext.Current.CurrentCustomer.Id == 0) { return(GetRedirect(model.EditLevel)); } if (_contextManager.RequestManager.Form[FormValuesNames.Return] != null) { return(GetRedirect(model.EditLevel, model.ServiceFunction.ServiceDomainId)); } if (ModelState.IsValid) { var serviceFunction = _serviceFunctionService.GetById(model.ServiceFunction.Id); if (serviceFunction == null) { return(GetRedirect(model.EditLevel, model.ServiceFunction.ServiceDomainId)); } var now = DateTime.Now; serviceFunction.FunctionTypeId = model.ServiceFunction.FunctionTypeId; serviceFunction.AlternativeName = model.ServiceFunction.AlternativeName; serviceFunction.DiagramOrder = model.ServiceFunction.DiagramOrder ?? 5; serviceFunction.UpdatedBy = _contextManager.UserManager.Name; serviceFunction.UpdatedDate = now; _serviceFunctionService.Update(Mapper.Map <ServiceFunction>(serviceFunction)); var customerSpecificTypeThreshold = _parameterService.GetParameterByNameAndCache <int>(ParameterNames.CustomerSpecificTypeThreshold); var functionType = _functionTypeRefDataService.GetById(serviceFunction.FunctionTypeId); if (!functionType.Visible && _functionTypeRefDataService.GetNumberOfFunctionTypeReferences(serviceFunction.FunctionTypeId) >= customerSpecificTypeThreshold) { functionType.Visible = true; _functionTypeRefDataService.Update(functionType); } return(GetRedirect(model.EditLevel, serviceFunction.ServiceDomainId)); } return(View("Edit" + model.EditLevel, model)); }
public void FunctionTypeRefDataService_GetById_CallsRepositoryGetById() { #region Arrange #endregion #region Act _functionTypeRefDataService.GetById(1); #endregion #region Assert _mockFunctionRefDataRepository.Verify(x => x.GetById(It.IsAny <int>()), Times.Once); #endregion }