コード例 #1
0
        private void TransformServiceFunction(ServiceDomain serviceDomain, TemplateRow templateRow)
        {
            var serviceFunction = serviceDomain.ServiceFunctions.FirstOrDefault(d => d.FunctionType.FunctionName.Trim() == templateRow.ServiceFunction.Trim());

            if (serviceFunction == null)
            {
                var dateTimeNow = DateTime.Now;
                serviceFunction = new ServiceFunction
                {
                    ServiceDomain     = serviceDomain,
                    FunctionType      = _functionTypeRefDataService.InsertorUpdate(templateRow.ServiceFunction),
                    ServiceComponents = new List <ServiceComponent>(),
                    DiagramOrder      = 5,
                    InsertedBy        = _userIdentity.Name,
                    InsertedDate      = dateTimeNow,
                    UpdatedBy         = _userIdentity.Name,
                    UpdatedDate       = dateTimeNow
                };

                serviceDomain.ServiceFunctions.Add(serviceFunction);
                _serviceDomainService.Update(serviceDomain);
            }

            if (!string.IsNullOrEmpty(templateRow.ServiceComponentLevel1))
            {
                TransformComponentLevelOne(serviceFunction, templateRow);
            }
        }
コード例 #2
0
        public void ServiceDomainService_Update_CallUpdateDomainAndCallsSaveChanges()
        {
            #region Arrange

            var dateTimeNow = DateTime.Now;

            var serviceDomain = new ServiceDomain()
            {
                Id          = 3,
                DomainType  = _serviceDomainTypes.FirstOrDefault(x => x.Id == 1),
                ServiceDesk = new ServiceDesk()
                {
                    Id = 1, DeskName = "Service Desk"
                },
                InsertedBy   = UserNameOne,
                InsertedDate = dateTimeNow,
                UpdatedBy    = UserNameOne,
                UpdatedDate  = dateTimeNow,
            };

            #endregion

            #region Act

            _serviceDomainService.Update(serviceDomain);

            #endregion

            #region Assert

            _mockServiceDomainRepository.Verify(x => x.Update(It.IsAny <ServiceDomain>()), Times.Once());
            _mockUnitOfWork.Verify(x => x.Save(), Times.Exactly(1));

            #endregion
        }
コード例 #3
0
        public ActionResult Edit(EditServiceDomainViewModel 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.ServiceDomain.ServiceDeskId));
            }

            if (ModelState.IsValid)
            {
                var serviceDomain = _serviceDomainService.GetById(model.ServiceDomain.Id);
                if (serviceDomain == null)
                {
                    return(GetRedirect(model.EditLevel, model.ServiceDomain.ServiceDeskId));
                }

                var now = DateTime.Now;

                serviceDomain.DomainTypeId    = model.ServiceDomain.DomainTypeId;
                serviceDomain.AlternativeName = model.ServiceDomain.AlternativeName;
                serviceDomain.DiagramOrder    = model.ServiceDomain.DiagramOrder ?? 5;
                serviceDomain.UpdatedBy       = _contextManager.UserManager.Name;
                serviceDomain.UpdatedDate     = now;

                _serviceDomainService.Update(Mapper.Map <ServiceDomain>(serviceDomain));

                var customerSpecificTypeThreshold = _parameterService.GetParameterByNameAndCache <int>(ParameterNames.CustomerSpecificTypeThreshold);
                var domainType = _domainTypeRefDataService.GetById(serviceDomain.DomainTypeId);
                if (!domainType.Visible && _domainTypeRefDataService.GetNumberOfDomainTypeReferences(serviceDomain.DomainTypeId) >= customerSpecificTypeThreshold)
                {
                    domainType.Visible = true;
                    _domainTypeRefDataService.Update(domainType);
                }


                return(GetRedirect(model.EditLevel, model.ServiceDomain.ServiceDeskId));
            }

            return(View("Edit" + model.EditLevel, model));
        }