Пример #1
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));
        }
Пример #2
0
        public ActionResult Edit(string level, int id)
        {
            var customerId = _appUserContext.Current.CurrentCustomer.Id;

            var customerDomainCount = _serviceDomainService
                                      .CustomerServiceDomains(customerId).Count();

            var serviceDomain = _serviceDomainService.GetById(id);

            var vm = new EditServiceDomainViewModel
            {
                ServiceDomain          = Mapper.Map <ServiceDomainViewModel>(serviceDomain),
                EditLevel              = level,
                CanMoveServiceFunction = customerDomainCount > 1,
            };

            return(View("Edit" + level, vm));
        }