示例#1
0
        public ActionResult EditLevel2(EditServiceComponentLevel2ViewModel model)
        {
            var preChecks = SaveServiceComponentPreChecks(model, ServiceComponentEditState.Level2);

            if (!preChecks.IsValid)
            {
                return(preChecks.Result);
            }

            var component = preChecks.ServiceComponent;

            component.ComponentName     = model.ComponentNameLevel.ComponentName;
            component.DiagramOrder      = model.ComponentNameLevel.DiagramOrder ?? 5;
            component.ServiceActivities = model.ServiceActivities.ServiceActivities;

            if (model.ComponentNameLevel.ComponentLevel == ServiceComponentLevel.Level1.ToString())
            {
                component.ComponentLevel = (int)ServiceComponentLevel.Level1;
                component.ParentServiceComponent.ChildServiceComponents = null;
                component.ParentServiceComponent = null;
            }

            var now      = preChecks.ServiceComponent.UpdatedDate;
            var userName = _contextManager.UserManager.Name;

            if (component.Resolver == null)
            {
                if (model.ResolverServiceDeliveryOrganisation.ServiceDeliveryOrganisationTypeId.HasValue &&
                    model.ResolverServiceDeliveryOrganisation.ServiceDeliveryOrganisationTypeId > 0)
                {
                    component.Resolver = new Resolver
                    {
                        ServiceDeskId = component.ServiceFunction.ServiceDomain.ServiceDeskId,
                        InsertedDate  = now,
                        InsertedBy    = userName,
                        UpdatedDate   = now,
                        UpdatedBy     = userName,
                    };

                    SaveServiceComponentResolver(component, model);
                }
            }
            else
            {
                SaveServiceComponentResolver(component, model);
            }

            _serviceComponentService.Update(component);

            return(GetRedirectAction(model.EditLevel, component.ServiceFunctionId, component.ParentServiceComponentId.Value));
        }
        public void EditServiceComponentLevel2ViewModelValidator_Validate_SdoTypeSelectedSdoNotesNotSupplied_IsValid()
        {
            var vm = new EditServiceComponentLevel2ViewModel
            {
                ResolverServiceDeliveryOrganisation = new EditResolverServiceDeliveryOrganisationViewModel
                {
                    ServiceDeliveryOrganisationTypeId = 1
                },
                ResolverServiceDeliveryUnit = new EditResolverServiceDeliveryUnitViewModel(),
                ResolverGroup = new EditResolverResolverGroupViewModel()
            };
            var result = _validator.Validate(vm);

            Assert.IsTrue(result.IsValid);
        }
        public void EditServiceComponentLevel2ViewModelValidator_Validate_SdoTypeNotSelected_IsValid()
        {
            var vm = new EditServiceComponentLevel2ViewModel
            {
                ServiceActivities = new ServiceActivityViewModel
                {
                    ServiceActivities = "- Activity One"
                },
                ResolverServiceDeliveryOrganisation = new EditResolverServiceDeliveryOrganisationViewModel(),
                ResolverServiceDeliveryUnit         = new EditResolverServiceDeliveryUnitViewModel(),
                ResolverGroup = new EditResolverResolverGroupViewModel()
            };
            var result = _validator.Validate(vm);

            Assert.IsTrue(result.IsValid);
        }
        public void EditServiceComponentLevel2ViewModelValidator_Validate_SdoTypeNotSelectedSdoNotesSupplied_IsValidationError()
        {
            var vm = new EditServiceComponentLevel2ViewModel
            {
                ResolverServiceDeliveryOrganisation = new EditResolverServiceDeliveryOrganisationViewModel
                {
                    ServiceDeliveryOrganisationNotes = "XXX"
                },
                ResolverServiceDeliveryUnit = new EditResolverServiceDeliveryUnitViewModel(),
                ResolverGroup = new EditResolverResolverGroupViewModel()
            };
            var result = _validator.Validate(vm);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(WebResources.ServiceComponentServiceDeliveryOrganisationTypeIdMustBeSupplied, result.Errors[0].ErrorMessage);
        }
        public void EditServiceComponentLevel2ViewModelValidator_Validate_SdoAndSduSupplied_IsValid()
        {
            var vm = new EditServiceComponentLevel2ViewModel
            {
                ResolverServiceDeliveryOrganisation = new EditResolverServiceDeliveryOrganisationViewModel
                {
                    ServiceDeliveryOrganisationTypeId = 1,
                    ServiceDeliveryOrganisationNotes  = "Notes are now valid with a type selected",
                },
                ResolverServiceDeliveryUnit = new EditResolverServiceDeliveryUnitViewModel
                {
                    ServiceDeliveryUnitTypeId = 1,
                    ServiceDeliveryUnitNotes  = "Notes are now valid with a type selected"
                },
                ResolverGroup = new EditResolverResolverGroupViewModel()
            };
            var result = _validator.Validate(vm);

            Assert.IsTrue(result.IsValid);
        }