private ActionResult Add(AddTemplateServiceDomainViewModel vm) { vm.ReturnUrl = vm.HasServiceDeskContext ? Url.Action("Edit", "ServiceDesk", new { level = vm.EditLevel, id = vm.ServiceDeskId }) : Url.Action("Index", "ServiceDomain", new { level = vm.EditLevel, id = vm.ServiceDeskId }); if (_appUserContext.Current?.CurrentCustomer != null && _appUserContext.Current.CurrentCustomer.Id > 0) { var customerId = _appUserContext.Current.CurrentCustomer.Id; var serviceDesks = _serviceDeskService.GetByCustomer(customerId).ToList(); if (vm.ServiceDeskId > 0) { vm.ServiceDeskName = serviceDesks.First(x => x.Id == vm.ServiceDeskId).DeskName; } else if (serviceDesks.Count == 1) { vm.ServiceDeskId = serviceDesks.First().Id; vm.ServiceDeskName = serviceDesks.First().DeskName; vm.HasServiceDeskContext = true; } else { vm.ServiceDesks.AddRange(serviceDesks.Select(s => new SelectListItem { Text = s.DeskName, Value = s.Id.ToString(CultureInfo.InvariantCulture) }).ToList()); } } return(View("Add" + vm.EditLevel, vm)); }
public ActionResult ServiceDeskStructure(int level) { if (_appUserContext.Current?.CurrentCustomer != null && _appUserContext.Current.CurrentCustomer.Id > 0) { var serviceDesks = _serviceDeskService.GetByCustomer(_appUserContext.Current.CurrentCustomer.Id); if (serviceDesks.Count() == 1) { // Go straight to the rendering the diagram return(RedirectToAction("ServiceDeskStructureDiagram", new { level, id = serviceDesks.First().Id })); } } return(View(level)); }
public ActionResult Edit(string level, int id) { if (_appUserContext.Current.CurrentCustomer == null || _appUserContext.Current.CurrentCustomer.Id == 0) { return(GetRedirect(level, null)); } var serviceDeskCount = _serviceDeskService .GetByCustomer(_appUserContext.Current.CurrentCustomer.Id) .Select(s => s.Id) .Count(); var serviceDesk = _serviceDeskService .GetByCustomerAndId(_appUserContext.Current.CurrentCustomer.Id, id); if (serviceDesk == null) { return(GetRedirect(level, _appUserContext.Current.CurrentCustomer.Id)); } var templates = _templateService.AllTemplates().ToList(); var vm = new EditServiceDeskViewModel { ServiceDesk = Mapper.Map <ServiceDeskViewModel>(serviceDesk), EditLevel = level, CanMoveServiceDomain = serviceDeskCount > 1, CanImportServiceConfiguratorTemplate = templates.Any(x => x.TemplateType == TemplateTypeNames.SORT), CanImportServiceLandscapeTemplate = templates.Any(x => x.TemplateType == TemplateTypeNames.SLM) }; return(View("Edit" + level, vm)); }
public void ServiceDeskService_GetByCustomer_ServiceDeskExistsWithCorrectCustomer_ResultReturned() { var result = _serviceDeskService.GetByCustomer(2); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count()); }
public ActionResult Index(string level) { var serviceDeskCount = _serviceDeskService .GetByCustomer(_appUserContext.Current.CurrentCustomer.Id) .Select(s => s.Id) .Count(); var templates = _templateService.AllTemplates().ToList(); var vm = new ViewServiceDomainViewModel { EditLevel = level, CanMoveServiceDomain = serviceDeskCount > 1, CanImportServiceConfiguratorTemplate = templates.Any(x => x.TemplateType == TemplateTypeNames.SORT), CanImportServiceLandscapeTemplate = templates.Any(x => x.TemplateType == TemplateTypeNames.SLM) }; return(View(level, vm)); }