Example #1
0
        private FormResult PostAdminForm(Form form)
        {
            // Check permissions
            _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

            // Get page and element identifiers
            string[] parts     = form.Context.Split('|');
            long     pageId    = Convert.ToInt64(parts[1]);
            long     elementId = Convert.ToInt64(parts[2]);

            // Get the tag cloud element service
            IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

            // Get updated form settings
            FormSettings formSettings = (FormSettings)elementService.New(_authenticationService.TenantId);

            formSettings.ElementId         = elementId;
            formSettings.Fields            = GetFields(elementId, form);
            formSettings.RecipientEmail    = ((MultiLineTextField)form.Fields["recipientEmail"]).Value;
            formSettings.SubmitButtonLabel = ((TextField)form.Fields["submitButtonLabel"]).Value;
            formSettings.SubmittedMessage  = ((TextField)form.Fields["submittedMessage"]).Value;

            // Perform the update
            elementService.Update(formSettings);

            // Return form result with no errors
            return(_formHelperService.GetFormResult());
        }
Example #2
0
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get page and element identifiers
                string[] parts     = form.Context.Split('|');
                long     pageId    = Convert.ToInt64(parts[0]);
                long     elementId = Convert.ToInt64(parts[1]);

                // Get the HTML element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated map settings
                MapSettings mapSettings = (MapSettings)elementService.New(_authenticationService.TenantId);
                mapSettings.ElementId   = elementId;
                mapSettings.DisplayName = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;

                // Get longitude and latitude
                double latitude;
                double longitude;
                string latitudeText     = ((TextField)form.Fields["latitude"]).Value;
                string longitudeText    = ((TextField)form.Fields["longitude"]).Value;
                bool   latitudeSuccess  = Double.TryParse(latitudeText, out latitude);
                bool   longitudeSuccess = Double.TryParse(longitudeText, out longitude);
                if (!latitudeSuccess)
                {
                    throw new ValidationErrorException(new ValidationError("latitude", ElementResource.MapLatitudeInvalidMessage));
                }
                if (!longitudeSuccess)
                {
                    throw new ValidationErrorException(new ValidationError("longitude", ElementResource.MapLongitudeInvalidMessage));
                }
                mapSettings.Latitude  = latitude;
                mapSettings.Longitude = longitude;

                // Perform the update
                elementService.Update(mapSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get page and element identifiers
                string[] parts     = form.Context.Split('|');
                long     pageId    = Convert.ToInt64(parts[0]);
                long     elementId = Convert.ToInt64(parts[1]);

                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get page header page
                string pageValue          = ((SelectListField <string>)form.Fields["page"]).Value;
                long?  pageHeaderPageId   = pageValue == string.Empty ? null : (long?)Convert.ToInt64(((SelectListField <string>)form.Fields["page"]).Value);
                long?  pageHeaderTenantId = pageHeaderPageId.HasValue ? (long?)tenantId : null;

                // Get the page header element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated page header settings
                PageHeaderSettings pageHeaderSettings = (PageHeaderSettings)elementService.New(_authenticationService.TenantId);
                pageHeaderSettings.ElementId       = elementId;
                pageHeaderSettings.PageId          = pageHeaderPageId;
                pageHeaderSettings.PageTenantId    = pageHeaderTenantId;
                pageHeaderSettings.ShowCreated     = ((BooleanField)form.Fields["showCreated"]).Value;
                pageHeaderSettings.ShowDescription = ((BooleanField)form.Fields["showDescription"]).Value;
                pageHeaderSettings.ShowImage       = ((BooleanField)form.Fields["showImage"]).Value;
                pageHeaderSettings.ShowName        = ((BooleanField)form.Fields["showName"]).Value;
                pageHeaderSettings.ShowOccurred    = ((BooleanField)form.Fields["showOccurred"]).Value;
                pageHeaderSettings.ShowUpdated     = ((BooleanField)form.Fields["showUpdated"]).Value;
                pageHeaderSettings.ShowBreadcrumbs = ((BooleanField)form.Fields["showBreadcrumbs"]).Value;

                // Perform the update
                elementService.Update(pageHeaderSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get page and element identifiers
                string[] parts     = form.Context.Split('|');
                long     pageId    = Convert.ToInt64(parts[0]);
                long     elementId = Convert.ToInt64(parts[1]);

                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get latest thread page
                string pageValue            = ((SelectListField <string>)form.Fields["page"]).Value;
                long?  latestThreadPageId   = pageValue == string.Empty ? null : (long?)Convert.ToInt64(((SelectListField <string>)form.Fields["page"]).Value);
                long?  latestThreadTenantId = latestThreadPageId.HasValue ? (long?)tenantId : null;

                // Get the latest thread element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated latest thread settings
                LatestThreadSettings latestThreadSettings = (LatestThreadSettings)elementService.New(_authenticationService.TenantId);
                latestThreadSettings.ElementId        = elementId;
                latestThreadSettings.DisplayName      = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
                latestThreadSettings.Preamble         = string.IsNullOrWhiteSpace(((MultiLineTextField)form.Fields["preamble"]).Value) ? null : ((MultiLineTextField)form.Fields["preamble"]).Value;
                latestThreadSettings.PageId           = latestThreadPageId;
                latestThreadSettings.PageTenantId     = latestThreadTenantId;
                latestThreadSettings.PageSize         = ((IntegerField)form.Fields["pageSize"]).Value.Value;
                latestThreadSettings.Recursive        = ((BooleanField)form.Fields["recursive"]).Value;
                latestThreadSettings.NoThreadsMessage = ((TextField)form.Fields["noThreadsMessage"]).Value;

                // Perform the update
                elementService.Update(latestThreadSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
Example #5
0
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get page and element identifiers
                string[] parts     = form.Context.Split('|');
                long     pageId    = Convert.ToInt64(parts[0]);
                long     elementId = Convert.ToInt64(parts[1]);

                // Get the share element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated share settings
                ShareSettings shareSettings = (ShareSettings)elementService.New(_authenticationService.TenantId);
                shareSettings.ElementId          = elementId;
                shareSettings.DisplayName        = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
                shareSettings.ShareOnDigg        = ((BooleanField)form.Fields["shareOnDigg"]).Value;
                shareSettings.ShareOnFacebook    = ((BooleanField)form.Fields["shareOnFacebook"]).Value;
                shareSettings.ShareOnGoogle      = ((BooleanField)form.Fields["shareOnGoogle"]).Value;
                shareSettings.ShareOnLinkedIn    = ((BooleanField)form.Fields["shareOnLinkedIn"]).Value;
                shareSettings.ShareOnPinterest   = ((BooleanField)form.Fields["shareOnPinterest"]).Value;
                shareSettings.ShareOnReddit      = ((BooleanField)form.Fields["shareOnReddit"]).Value;
                shareSettings.ShareOnStumbleUpon = ((BooleanField)form.Fields["shareOnStumbleUpon"]).Value;
                shareSettings.ShareOnTumblr      = ((BooleanField)form.Fields["shareOnTumblr"]).Value;
                shareSettings.ShareOnTwitter     = ((BooleanField)form.Fields["shareOnTwitter"]).Value;

                // Perform the update
                elementService.Update(shareSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get page and element identifiers
                string[] parts     = form.Context.Split('|');
                long     pageId    = Convert.ToInt64(parts[0]);
                long     elementId = Convert.ToInt64(parts[1]);

                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get the nav bar element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get existing nav bar settings
                NavBarSettings navBarSettings = (NavBarSettings)elementService.New(_authenticationService.TenantId);
                navBarSettings.ElementId = elementId;

                // Update nav bar settings
                navBarSettings.Tabs       = GetTabs(tenantId, elementId, form);
                navBarSettings.NavBarName = string.IsNullOrWhiteSpace(((TextField)form.Fields["navBarName"]).Value) ? null : ((TextField)form.Fields["navBarName"]).Value;
                navBarSettings.ShowLoggedOffUserOptions = ((BooleanField)form.Fields["showLoggedOffUserOptions"]).Value;
                navBarSettings.ShowLoggedOnUserOptions  = ((BooleanField)form.Fields["showLoggedOnUserOptions"]).Value;

                // Perform the update
                elementService.Update(navBarSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
Example #7
0
        private void PostSlidesForm(Form form, long pageId, long elementId)
        {
            // Get tenant ID
            long tenantId = _authenticationService.TenantId;

            // Get element service
            IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

            // Get updated carousel settings
            CarouselSettings carouselSettings = (CarouselSettings)elementService.New(_authenticationService.TenantId);

            carouselSettings.ElementId = elementId;
            carouselSettings.Slides    = new List <CarouselSlide>();
            List <CarouselSlideViewModel> slideViewModels = JsonConvert.DeserializeObject <List <CarouselSlideViewModel> >(form.Data);

            for (int index = 0; index < slideViewModels.Count; index++)
            {
                CarouselSlideViewModel slideViewModel = slideViewModels[index];
                carouselSettings.Slides.Add(new CarouselSlide
                {
                    CarouselSlideId        = Convert.ToInt64(slideViewModel.CarouselSlideId),
                    Description            = slideViewModel.Description,
                    ElementId              = elementId,
                    ImageTenantId          = tenantId,
                    ImageUploadId          = Convert.ToInt64(slideViewModel.ImageUploadId),
                    Name                   = slideViewModel.Name,
                    PageId                 = string.IsNullOrWhiteSpace(slideViewModel.PageId) ? null : (long?)Convert.ToInt64(slideViewModel.PageId),
                    PageText               = string.IsNullOrWhiteSpace(slideViewModel.PageText) ? null : slideViewModel.PageText,
                    PageTenantId           = string.IsNullOrWhiteSpace(slideViewModel.PageId) ? null : (long?)tenantId,
                    PreviewImageUploadId   = Convert.ToInt64(slideViewModel.PreviewImageUploadId),
                    SortOrder              = index,
                    TenantId               = tenantId,
                    ThumbnailImageUploadId = Convert.ToInt64(slideViewModel.ThumbnailImageUploadId)
                });
            }

            // Perform the update
            elementService.Update(carouselSettings);
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get page and element identifiers
                string[] parts     = form.Context.Split('|');
                long     pageId    = Convert.ToInt64(parts[0]);
                long     elementId = Convert.ToInt64(parts[1]);

                // Get the code snippet element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated code snippet settings
                CodeSnippetSettings codeSnippetSettings = (CodeSnippetSettings)elementService.New(_authenticationService.TenantId);
                codeSnippetSettings.ElementId = elementId;
                codeSnippetSettings.Code      = ((MultiLineTextField)form.Fields["code"]).Value;
                codeSnippetSettings.Language  = (Language)Convert.ToInt32(((SelectListField <string>)form.Fields["language"]).Value);

                // Perform the update
                elementService.Update(codeSnippetSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get page and element identifiers
                string[] parts = form.Context.Split('|');
                long pageId = Convert.ToInt64(parts[0]);
                long elementId = Convert.ToInt64(parts[1]);

                // Get the HTML element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated HTML settings
                HtmlSettings htmlSettings = (HtmlSettings)elementService.New(_authenticationService.TenantId);
                htmlSettings.ElementId = elementId;
                htmlSettings.Html = ((MultiLineTextField)form.Fields["html"]).Value;

                // Perform the update
                elementService.Update(htmlSettings);

                // Return form result with no errors
                return _formHelperService.GetFormResult();
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return _formHelperService.GetFormResultWithValidationErrors(ex.Errors);
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return _formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage);
            }
        }
Example #10
0
 /// <summary>
 /// Updates an element's details.
 /// </summary>
 /// <param name="settings">Updated element details.</param>
 /// <param name="unitOfWork">Unit of work.</param>
 public void Update(IElementSettings settings, IUnitOfWork unitOfWork = null)
 {
     try
     {
         IAdvancedElementService customElementService   = (IAdvancedElementService)_elementFactory.GetElementService(settings.ElementTypeId);
         ICustomElementValidator customElementValidator = _elementFactory.GetElementValidator(settings.ElementTypeId);
         if (customElementValidator != null)
         {
             customElementValidator.ValidateUpdate(settings, unitOfWork);
         }
         if (customElementService != null)
         {
             customElementService.Update(settings, unitOfWork);
         }
     }
     catch (ValidationErrorException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new ValidationErrorException(new ValidationError(null, ApplicationResource.UnexpectedErrorMessage), ex);
     }
 }
Example #11
0
        private void PostPhotosForm(Form form, long pageId, long elementId)
        {
            // Get tenant ID
            long tenantId = _authenticationService.TenantId;

            // Get element service
            IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

            // Get updated album settings
            AlbumSettings albumSettings = (AlbumSettings)elementService.New(_authenticationService.TenantId);

            albumSettings.ElementId   = elementId;
            albumSettings.DisplayName = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
            albumSettings.Photos      = new List <AlbumPhoto>();
            List <AlbumPhotoViewModel> photoViewModels = JsonConvert.DeserializeObject <List <AlbumPhotoViewModel> >(form.Data);

            for (int index = 0; index < photoViewModels.Count; index++)
            {
                AlbumPhotoViewModel photoViewModel = photoViewModels[index];
                albumSettings.Photos.Add(new AlbumPhoto {
                    AlbumPhotoId           = Convert.ToInt64(photoViewModel.AlbumPhotoId),
                    Description            = photoViewModel.Description,
                    ElementId              = elementId,
                    ImageTenantId          = tenantId,
                    ImageUploadId          = Convert.ToInt64(photoViewModel.ImageUploadId),
                    Name                   = photoViewModel.Name,
                    PreviewImageUploadId   = Convert.ToInt64(photoViewModel.PreviewImageUploadId),
                    SortOrder              = index,
                    TenantId               = tenantId,
                    ThumbnailImageUploadId = Convert.ToInt64(photoViewModel.ThumbnailImageUploadId)
                });
            }

            // Perform the update
            elementService.Update(albumSettings);
        }
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get page and element identifiers
                string[] parts     = form.Context.Split('|');
                long     pageId    = Convert.ToInt64(parts[0]);
                long     elementId = Convert.ToInt64(parts[1]);

                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get sort by enumeration value
                PageSortBy sortBy;
                Enum.TryParse <PageSortBy>(((SelectListField <string>)form.Fields["sortBy"]).Value, out sortBy);

                // Get page type enumeration value
                PageType pageType;
                Enum.TryParse <PageType>(((SelectListField <string>)form.Fields["pageType"]).Value, out pageType);

                // Get Booleans
                bool sortAsc;
                Boolean.TryParse(((SelectListField <string>)form.Fields["sortAsc"]).Value, out sortAsc);

                // Get page list page
                string pageValue        = ((SelectListField <string>)form.Fields["page"]).Value;
                long?  pageListPageId   = pageValue == string.Empty ? null : (long?)Convert.ToInt64(((SelectListField <string>)form.Fields["page"]).Value);
                long?  pageListTenantId = pageListPageId.HasValue ? (long?)tenantId : null;

                // Get the page list element service
                IAdvancedElementService elementService = (IAdvancedElementService)_elementFactory.GetElementService(FormId);

                // Get updated page list settings
                PageListSettings pageListSettings = (PageListSettings)elementService.New(_authenticationService.TenantId);
                pageListSettings.ElementId           = elementId;
                pageListSettings.DisplayName         = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
                pageListSettings.PageId              = pageListPageId;
                pageListSettings.PageTenantId        = pageListTenantId;
                pageListSettings.SortBy              = sortBy;
                pageListSettings.SortAsc             = sortAsc;
                pageListSettings.ShowRelated         = ((BooleanField)form.Fields["showRelated"]).Value;
                pageListSettings.ShowDescription     = ((BooleanField)form.Fields["showDescription"]).Value;
                pageListSettings.ShowImage           = ((BooleanField)form.Fields["showImage"]).Value;
                pageListSettings.ShowBackgroundImage = ((BooleanField)form.Fields["showBackgroundImage"]).Value;
                pageListSettings.ShowCreated         = ((BooleanField)form.Fields["showCreated"]).Value;
                pageListSettings.ShowUpdated         = ((BooleanField)form.Fields["showUpdated"]).Value;
                pageListSettings.ShowOccurred        = ((BooleanField)form.Fields["showOccurred"]).Value;
                pageListSettings.ShowComments        = ((BooleanField)form.Fields["showComments"]).Value;
                pageListSettings.ShowTags            = ((BooleanField)form.Fields["showTags"]).Value;
                pageListSettings.PageSize            = ((IntegerField)form.Fields["pageSize"]).Value.Value;
                pageListSettings.ShowPager           = ((BooleanField)form.Fields["showPager"]).Value;
                pageListSettings.MoreMessage         = ((TextField)form.Fields["moreMessage"]).Value;
                pageListSettings.Recursive           = ((BooleanField)form.Fields["recursive"]).Value;
                pageListSettings.PageType            = pageType;
                pageListSettings.NoPagesMessage      = string.IsNullOrWhiteSpace(((TextField)form.Fields["noPagesMessage"]).Value) ? null : ((TextField)form.Fields["noPagesMessage"]).Value;
                pageListSettings.Preamble            = string.IsNullOrWhiteSpace(((MultiLineTextField)form.Fields["preamble"]).Value) ? null : ((MultiLineTextField)form.Fields["preamble"]).Value;

                // Perform the update
                elementService.Update(pageListSettings);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (ValidationErrorException ex)
            {
                // Return form result containing errors
                return(_formHelperService.GetFormResultWithValidationErrors(ex.Errors));
            }
            catch (Exception)
            {
                // Return form result containing unexpected error message
                return(_formHelperService.GetFormResultWithErrorMessage(ApplicationResource.UnexpectedErrorMessage));
            }
        }