Beispiel #1
0
        public void EditServiceComponentLevel1WithNoChildComponentOrResolverViewModelValidator_Validate_SdoTypeNotSelectedSdoNotesSupplied_IsValidationError()
        {
            var vm = new EditServiceComponentLevel1WithNoChildComponentOrResolverViewModel
            {
                ComponentName = new EditServiceComponentNameViewModel
                {
                    ComponentName = "XXX"
                },
                ServiceActivities = new ServiceActivityViewModel
                {
                    ServiceActivities = "- Activity One"
                },
                InputMode = 0,
                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);
        }
Beispiel #2
0
        public void EditServiceComponentLevel1WithNoChildComponentOrResolverViewModelValidator_Validate_SdoTypeSelectedSdoNotesSupplied_IsValid()
        {
            var vm = new EditServiceComponentLevel1WithNoChildComponentOrResolverViewModel
            {
                ComponentName = new EditServiceComponentNameViewModel
                {
                    ComponentName = "XXX"
                },
                ServiceActivities = new ServiceActivityViewModel
                {
                    ServiceActivities = "- Activity One"
                },
                InputMode = 0,
                ResolverServiceDeliveryOrganisation = new EditResolverServiceDeliveryOrganisationViewModel
                {
                    ServiceDeliveryOrganisationTypeId = 1,
                    ServiceDeliveryOrganisationNotes  = "Notes are now valid with a type selected",
                },
                ResolverServiceDeliveryUnit = new EditResolverServiceDeliveryUnitViewModel(),
                ResolverGroup = new EditResolverResolverGroupViewModel()
            };
            var result = _validator.Validate(vm);

            Assert.IsTrue(result.IsValid);
        }
Beispiel #3
0
        public ActionResult EditLevel1WithNoChildComponentOrResolver(EditServiceComponentLevel1WithNoChildComponentOrResolverViewModel model)
        {
            var preChecks = SaveServiceComponentPreChecks(model, ServiceComponentEditState.Level1WithNoChildComponentOrResolver);

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

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

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

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

                    SaveServiceComponentResolver(component, model);
                }
            }
            else if (model.InputMode == 1)
            {
                // Add Child Component
                if (!string.IsNullOrEmpty(model.ChildComponent.ComponentName))
                {
                    var childServiceComponent = new ServiceComponent
                    {
                        ComponentLevel    = (int)ServiceComponentLevel.Level2,
                        ComponentName     = model.ChildComponent.ComponentName,
                        ServiceFunctionId = component.ServiceFunctionId,
                        InsertedBy        = userName,
                        InsertedDate      = now,
                        UpdatedBy         = userName,
                        UpdatedDate       = now
                    };

                    if (component.ChildServiceComponents != null)
                    {
                        component.ChildServiceComponents.Add(childServiceComponent);
                    }
                    else
                    {
                        component.ChildServiceComponents = new List <ServiceComponent> {
                            childServiceComponent
                        };
                    }
                }
            }

            component.UpdatedDate = now;
            component.UpdatedBy   = userName;

            _serviceComponentService.Update(component);

            return(GetRedirectAction(model.EditLevel, component.ServiceFunctionId));
        }