Example #1
0
        public ActionResult CreateBatch()
        {
            SubsiteBatchDto             instance = new SubsiteBatchDto();
            SubsiteBatchCreateViewModel model    = new SubsiteBatchCreateViewModel(instance);

            return(View(model));
        }
Example #2
0
        public ActionResult CreateBatch(FormCollection formData)
        {
            SubsiteBatchDto             instance = new SubsiteBatchDto();
            SubsiteBatchCreateViewModel model    = new SubsiteBatchCreateViewModel(instance);

            UpdateModel(instance, formData);
            if (ModelState.IsValid)
            {
                Random randomValue = new Random();
                for (int index = 1; index <= instance.Total; index++)
                {
                    string instanceName = string.Format("{0}{1}", instance.NameStem, index);
                    int    sort         = 201 + index;
                    int    languageId   = randomValue.Next(CmsRegister.MIN_LANGUAGE_ID, CmsRegister.MAX_LANGUAGE_ID + 1);
                    int    locationId   = randomValue.Next(CmsRegister.MIN_LOCATION_ID, CmsRegister.MAX_LOCATION_ID + 1);
                    int    categoryId   = randomValue.Next(CmsRegister.MIN_CATEGORY_ID, CmsRegister.MAX_CATEGORY_ID + 1);
                    if (instance.DefaultLanguageId != null)
                    {
                        languageId = instance.DefaultLanguageId.Value;
                    }
                    if (instance.DefaultLocationId != null)
                    {
                        locationId = instance.DefaultLocationId.Value;
                    }
                    string         serviceLandingName = "Service";
                    string         serviceLandingSlug = "service";
                    string         eventLandingName   = "Event";
                    string         eventLandingSlug   = "event";
                    FolderTreeData tree    = CreateFolderTreeOfSupplier(instanceName, serviceLandingName, serviceLandingSlug, eventLandingName, eventLandingSlug, CmsRegister.CONTENT_FOLDER_ID, sort, categoryId, locationId, true);
                    SubsiteDto     subsite = CreateSubsite(instanceName, languageId, locationId);
                    IFacadeUpdateResult <FolderData> result = Service.SaveSubsiteWhole(tree, subsite);
                    if (!result.IsSuccessful)
                    {
                        ProcUpdateResult(result.ValidationResult, result.Exception);
                        break;
                    }
                }
            }

            return(View(model));
        }