public void OperationalProcessTypeRefDataService_GetAll_CallsRepositoryAll() { #region Arrange #endregion #region Act _operationalProcessTypeRefDataService.All(); #endregion #region Assert _mockOperationalProcessTypeRefDataRepository.Verify(x => x.All(), Times.Once); #endregion }
public ActionResult UpdateAjaxDotMatrixGrid([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable <Dictionary <string, string> > model) { DataSourceResult result = null; try { if (_appUserContext.Current?.CurrentCustomer != null && _appUserContext.Current.CurrentCustomer.Id > 0) { var updateResolverGroups = new List <Resolver>(); List <OperationalProcessTypeRefData> opProcRefs = _operationalProcessTypeRefDataService .All() .ToList(); foreach (var resolverGroup in model) { var resolverGroupId = int.Parse(resolverGroup[DotMatrixNames.ResolverId]); var updateResolverGroup = _resolverService .GetByCustomer(_appUserContext.Current.CurrentCustomer.Id) .SingleOrDefault(x => x.Id == resolverGroupId); if (updateResolverGroup == null) { ModelState.AddModelError(ModelStateErrorNames.ResolverGroupCannotBeFound, WebResources.ResolverGroupCannotBeFound); break; } if (updateResolverGroup.OperationalProcessTypes == null) { updateResolverGroup.OperationalProcessTypes = new List <OperationalProcessType>(); } else { updateResolverGroup.OperationalProcessTypes.Clear(); } var opProcIds = resolverGroup .Where(x => x.Key.StartsWith(DotMatrixNames.OpIdPrefix) && bool.Parse(x.Value)) .Select(s => int.Parse(s.Key.Replace(DotMatrixNames.OpIdPrefix, string.Empty))) .ToList(); foreach (var opProcId in opProcIds) { if (opProcRefs.Any(x => x.Id == opProcId)) { var opProcRef = opProcRefs .Single(x => x.Id == opProcId); updateResolverGroup.OperationalProcessTypes.Add(new OperationalProcessType { OperationalProcessTypeRefData = opProcRef, Resolver = updateResolverGroup }); } } updateResolverGroup.UpdatedBy = _contextManager.UserManager.Name; updateResolverGroup.UpdatedDate = DateTime.Now; updateResolverGroups.Add(updateResolverGroup); } if (updateResolverGroups.Any()) { _resolverService.Update(updateResolverGroups); } result = _resolverService .GetDotMatrix(_appUserContext.Current.CurrentCustomer.Id, false) .ToDataSourceResult(request, ModelState, Mapper.Map <Dictionary <string, object> >); } } catch (Exception ex) { _contextManager.ResponseManager.StatusCode = 500; _contextManager.ResponseManager.AppendHeader(ModelStateErrorNames.ErrorMessage, ex.Message); } return(Json(result)); }