private void TransformServiceDomain(ServiceDesk serviceDesk, TemplateRow templateRow)
        {
            var serviceDomain = serviceDesk.ServiceDomains.FirstOrDefault(d => d.DomainType.DomainName.Trim() == templateRow.ServiceDomain.Trim());

            if (serviceDomain == null)
            {
                var dateTimeNow = DateTime.Now;
                serviceDomain = new ServiceDomain
                {
                    DomainType       = _domainTypeRefDataService.InsertorUpdate(templateRow.ServiceDomain),
                    ServiceFunctions = new List <ServiceFunction>(),
                    DiagramOrder     = 5,
                    InsertedBy       = _userIdentity.Name,
                    InsertedDate     = dateTimeNow,
                    UpdatedBy        = _userIdentity.Name,
                    UpdatedDate      = dateTimeNow
                };

                serviceDesk.ServiceDomains.Add(serviceDomain);
                _serviceDeskService.Update(serviceDesk);
            }

            if (!string.IsNullOrEmpty(templateRow.ServiceFunction))
            {
                TransformServiceFunction(serviceDomain, templateRow);
            }
        }
Ejemplo n.º 2
0
        public void ServiceDeskService_Update_CallUpdateServiceDeskAndCallsSaveChanges()
        {
            #region Arrange

            var dateTimeNow = DateTime.Now;

            var serviceDesk = new ServiceDesk
            {
                Id          = 2,
                CustomerId  = 1,
                DeskName    = "Fujitsu Service Desk",
                UpdatedBy   = UserNameOne,
                UpdatedDate = dateTimeNow,
            };

            #endregion

            #region Act

            _serviceDeskService.Update(serviceDesk);

            #endregion

            #region Assert

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

            #endregion
        }
Ejemplo n.º 3
0
        public ActionResult Edit(string level, int id, string deskName, int[] deskInputTypes)
        {
            if (_appUserContext.Current.CurrentCustomer == null ||
                _appUserContext.Current.CurrentCustomer.Id == 0)
            {
                return(GetRedirect(level, null));
            }
            var customerId = _appUserContext.Current.CurrentCustomer.Id;

            if (_contextManager.RequestManager.Form[FormValuesNames.Return] != null)
            {
                return(GetRedirect(level, customerId));
            }

            var serviceDesk = _serviceDeskService.GetByCustomerAndId(customerId, id);

            if (serviceDesk == null)
            {
                return(GetRedirect(level, _appUserContext.Current.CurrentCustomer.Id));
            }

            if (ModelState.IsValid)
            {
                var now = DateTime.Now;

                serviceDesk.DeskName    = deskName;
                serviceDesk.UpdatedBy   = _contextManager.UserManager.Name;
                serviceDesk.UpdatedDate = now;

                // Add Desk Input Types
                if (deskInputTypes != null && deskInputTypes.Length > 0)
                {
                    // Remove Desk Input Types
                    var deletedDeskInputTypes = serviceDesk
                                                .DeskInputTypes
                                                .RemoveAll(x => !deskInputTypes.Any(y => y == x.InputTypeRefData.Id))
                                                .Select(s => s.Id)
                                                .ToList();

                    var newDeskInputTypeIds =
                        deskInputTypes.Where(x => serviceDesk.DeskInputTypes.All(y => y.InputTypeRefData.Id != x));

                    foreach (var deskInputTypeId in newDeskInputTypeIds)
                    {
                        serviceDesk.DeskInputTypes.Add(new DeskInputType
                        {
                            InputTypeRefData = _inputTypeRefDataService.GetById(deskInputTypeId)
                        });
                    }

                    _serviceDeskService.Update(serviceDesk, deletedDeskInputTypes);
                }
                else
                {
                    // Remove all of the Desk Input Types
                    if (serviceDesk.DeskInputTypes.Any())
                    {
                        var deletedDeskInputTypes = serviceDesk
                                                    .DeskInputTypes
                                                    .Select(s => s.Id)
                                                    .ToList();

                        _serviceDeskService.Update(serviceDesk, deletedDeskInputTypes);
                    }
                    else
                    {
                        _serviceDeskService.Update(serviceDesk);
                    }
                }

                return(GetRedirect(level, _appUserContext.Current.CurrentCustomer.Id));
            }

            var templates = _templateService.AllTemplates().ToList();

            var vm = new EditServiceDeskViewModel
            {
                EditLevel   = level,
                ServiceDesk = Mapper.Map <ServiceDeskViewModel>(serviceDesk),
                CanImportServiceConfiguratorTemplate = templates.Any(x => x.TemplateType == TemplateTypeNames.SORT),
                CanImportServiceLandscapeTemplate    = templates.Any(x => x.TemplateType == TemplateTypeNames.SLM)
            };

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