public FormResult PostUpload(string id, string context, string name, string contentType, byte[] content)
        {
            try
            {
                // Check permissions
                _authenticationService.EnsureLoggedOnUser();

                // The form result
                FormResult formResult = null;

                // Split context into different parts
                string action = context.Split('|')[0];

                // Perform the correct action based on form context
                switch (action)
                {
                case "updateuser":
                    formResult = PostUpdateUserUpload(id, context, name, contentType, content);
                    break;
                }

                // Return result
                return(formResult);
            }
            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));
            }
        }
        /// <summary>
        /// Submits form.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        public FormResult PostForm(Form form)
        {
            try
            {
                // Get action
                string action = GetAction(form.Context);

                // Perform action based on form context
                switch (action)
                {
                case "create":
                    _authorizationService.AuthorizeUserForFunction(Functions.CreateMasterPages);
                    return(CreateMasterPage(form));

                case "update":
                    _authorizationService.AuthorizeUserForFunction(Functions.UpdateMasterPages);
                    return(UpdateMasterPage(form));

                default:
                    return(null);
                }
            }
            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));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Submits form.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        public FormResult PostForm(Form form)
        {
            try
            {
                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get confirm user set password model from submitted form values
                LogonModel model = new LogonModel
                {
                    Email      = ((TextField)form.Fields["email"]).Value,
                    Password   = ((PasswordTextField)form.Fields["password"]).Value,
                    RememberMe = ((BooleanField)form.Fields["rememberMe"]).Value,
                    TenantId   = tenantId
                };

                // Log user on
                _authenticationService.Logon(model);

                // 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));
            }
        }
        /// <summary>
        /// Submits form.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        public FormResult PostForm(Form form)
        {
            try
            {
                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get confirm user set password model from submitted form values
                ConfirmUserSetPasswordModel model = new ConfirmUserSetPasswordModel
                {
                    Password        = ((PasswordTextField)form.Fields["password"]).Value,
                    ConfirmPassword = ((PasswordTextField)form.Fields["confirmPassword"]).Value,
                    ConfirmKey      = form.Context,
                    TenantId        = tenantId
                };

                // Confirm user and set password
                _authenticationService.ConfirmUserSetPassword(model);

                // 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));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Submits form.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        public FormResult PostForm(Form form)
        {
            try
            {
                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get new profile details from form values
                ForgottenPasswordModel model = new ForgottenPasswordModel
                {
                    Email    = ((TextField)form.Fields["email"]).Value,
                    TenantId = tenantId
                };

                // Initiate password reset
                _authenticationService.ForgottenPassword(model);

                // 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));
            }
        }
Ejemplo n.º 6
0
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // Get tenant, page and page zone identifiers
                string[] parts      = form.Context.Split('|');
                long     pageId     = Convert.ToInt64(parts[0]);
                long     pageZoneId = Convert.ToInt64(parts[1]);
                long     tenantId   = _authenticationService.TenantId;

                // Get page zone info
                List <PageZoneElementInfo> pageZoneElements = GetElements(form);

                // Update page zone
                _pageService.UpdateZone(tenantId, pageId, pageZoneId, pageZoneElements);

                // 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));
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Submits form.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        public FormResult PostForm(Form form)
        {
            try
            {
                // Get website identifier
                long tenantId = _authenticationService.TenantId;

                // Get create user model from submitted form values
                CreateUserModel model = new CreateUserModel
                {
                    Alias    = ((TextField)form.Fields["alias"]).Value,
                    Email    = ((TextField)form.Fields["email"]).Value,
                    TenantId = tenantId
                };

                // Create user
                long userId = _authenticationService.CreateUser(model);

                // 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));
            }
        }
Ejemplo n.º 8
0
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // The form result
                FormResult formResult = null;

                // Split context into different parts
                string action = form.Context.Split('|')[0];

                // Perform the correct action based on form context
                switch (action)
                {
                case "createthread":
                    formResult = PostCreateThreadForm(form);
                    break;

                case "updatethread":
                    formResult = PostUpdateThreadForm(form);
                    break;

                case "replythread":
                case "quotethread":
                    formResult = PostReplyQuoteThreadForm(form);
                    break;

                case "replypost":
                case "quotepost":
                    formResult = PostReplyQuotePostForm(form);
                    break;

                case "updatepost":
                    formResult = PostUpdatePostForm(form);
                    break;

                case "deletethread":
                    formResult = PostDeleteThreadForm(form);
                    break;
                }

                // Return result
                return(formResult);
            }
            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));
            }
        }
Ejemplo n.º 9
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));
            }
        }
Ejemplo n.º 10
0
        public FormResult PostUpload(string id, string context, string name, string contentType, byte[] content)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

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

                // Get upload model
                long tenantId = _authenticationService.TenantId;
                CreateUploadModel model = new CreateUploadModel
                {
                    Content = content,
                    ContentType = contentType,
                    Name = name,
                    TenantId = tenantId
                };

                // Create uploads, ready to be assigned to HTML element when form submitted
                IUploadElementService htmlService = (IUploadElementService)_elementFactory.GetElementService(FormId);
                long htmlUploadId = htmlService.PrepareImages(tenantId, elementId, model);

                // Return form result
                string status = _htmlUrlService.GetHtmlUploadUrl(elementId, htmlUploadId);
                return _formHelperService.GetFormResult(status);
            }
            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));
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles form upload.
        /// </summary>
        /// <param name="id">Form identifier.</param>
        /// <param name="context">Form context.</param>
        /// <param name="name">The name of the upload (e.g. "MyImage.png").</param>
        /// <param name="contentType">The type of the upload content (e.g. "image/png").</param>
        /// <param name="content">Byte buffer containing uploaded content.</param>
        /// <returns>Result of form upload post.</returns>
        public FormResult PostUpload(string id, string context, string name, string contentType, byte[] content)
        {
            try
            {
                // The form result
                FormResult formResult = null;

                // Split context into different parts
                string action = context.Split('|')[0];

                // Perform the correct action based on form context
                switch (action)
                {
                case "create":
                    _authorizationService.AuthorizeUserForFunction(Functions.CreatePages);
                    formResult = PostCreateUpload(id, context, name, contentType, content);
                    break;

                case "update":
                    _authorizationService.AuthorizeUserForFunction(Functions.UpdatePages);
                    formResult = PostUpdateUpload(id, context, name, contentType, content);
                    break;
                }

                // Return result
                return(formResult);
            }
            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));
            }
        }
Ejemplo n.º 14
0
        public FormResult PostUpload(string id, string context, string name, string contentType, byte[] content)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdatePageElements);

                // The form result
                FormResult formResult = null;

                // Split context into different parts
                string[] parts     = context.Split('|');
                long     pageId    = Convert.ToInt64(parts[1]);
                long     elementId = Convert.ToInt64(parts[2]);
                string   action    = parts[0];

                // Perform the correct action based on form context
                switch (action)
                {
                case "photo":
                    formResult = PostCreateUpload(elementId, name, contentType, content);
                    break;
                }

                // Return result
                return(formResult);
            }
            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));
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Submits form.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        public FormResult PostForm(Form form)
        {
            long tenantId = _authenticationService.TenantId;

            try
            {
                // Check permissions
                _authenticationService.EnsureLoggedOnUser();

                // Get user identifier
                long userId = _authenticationService.GetCurrentUser().User.UserId;

                // Get change password model from submitted form values
                ChangePasswordModel model = new ChangePasswordModel
                {
                    CurrentPassword = ((PasswordTextField)form.Fields["currentPassword"]).Value,
                    NewPassword     = ((PasswordTextField)form.Fields["newPassword"]).Value,
                    ConfirmPassword = ((PasswordTextField)form.Fields["confirmPassword"]).Value,
                    TenantId        = tenantId,
                    UserId          = userId
                };

                // Change user password
                _authenticationService.ChangePassword(model);

                // Return form result with no errors
                return(_formHelperService.GetFormResult());
            }
            catch (UserLockedOutException)
            {
                // Log user off
                _authenticationService.Logoff();

                // Return form result with status locked out
                return(_formHelperService.GetFormResult("lockedout"));
            }
            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));
            }
        }
Ejemplo n.º 16
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));
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Submits form.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        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 updated settings
                ContactSettings settings = (ContactSettings)New(_authenticationService.TenantId);
                settings.ElementId                = elementId;
                settings.DisplayName              = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? null : ((TextField)form.Fields["displayName"]).Value;
                settings.Preamble                 = string.IsNullOrWhiteSpace(((MultiLineTextField)form.Fields["preamble"]).Value) ? null : ((MultiLineTextField)form.Fields["preamble"]).Value;
                settings.Address                  = string.IsNullOrWhiteSpace(((TextField)form.Fields["address"]).Value) ? null : ((TextField)form.Fields["address"]).Value;
                settings.Email                    = string.IsNullOrWhiteSpace(((TextField)form.Fields["email"]).Value) ? null : ((TextField)form.Fields["email"]).Value;
                settings.FacebookUsername         = string.IsNullOrWhiteSpace(((TextField)form.Fields["facebookUsername"]).Value) ? null : ((TextField)form.Fields["facebookUsername"]).Value;
                settings.InstagramUsername        = string.IsNullOrWhiteSpace(((TextField)form.Fields["instagramUsername"]).Value) ? null : ((TextField)form.Fields["instagramUsername"]).Value;
                settings.LinkedInCompanyUsername  = string.IsNullOrWhiteSpace(((TextField)form.Fields["linkedInCompanyUsername"]).Value) ? null : ((TextField)form.Fields["linkedInCompanyUsername"]).Value;
                settings.LinkedInPersonalUsername = string.IsNullOrWhiteSpace(((TextField)form.Fields["linkedInPersonalUsername"]).Value) ? null : ((TextField)form.Fields["linkedInPersonalUsername"]).Value;
                settings.TelephoneNumber1         = string.IsNullOrWhiteSpace(((TextField)form.Fields["telephoneNumber1"]).Value) ? null : ((TextField)form.Fields["telephoneNumber1"]).Value;
                settings.TelephoneNumber2         = string.IsNullOrWhiteSpace(((TextField)form.Fields["telephoneNumber2"]).Value) ? null : ((TextField)form.Fields["telephoneNumber2"]).Value;
                settings.TwitterUsername          = string.IsNullOrWhiteSpace(((TextField)form.Fields["twitterUsername"]).Value) ? null : ((TextField)form.Fields["twitterUsername"]).Value;
                settings.YouTubeChannelId         = string.IsNullOrWhiteSpace(((TextField)form.Fields["youTubeChannelId"]).Value) ? null : ((TextField)form.Fields["youTubeChannelId"]).Value;

                // Perform the update
                Update(settings);

                // 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));
            }
        }
        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));
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Submits form to update table element.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        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 updated settings
                TableSettings settings = (TableSettings)New(_authenticationService.TenantId);
                settings.ElementId   = elementId;
                settings.DisplayName = string.IsNullOrWhiteSpace(((TextField)form.Fields["displayName"]).Value) ? string.Empty : ((TextField)form.Fields["displayName"]).Value;
                settings.Preamble    = string.IsNullOrWhiteSpace(((MultiLineTextField)form.Fields["preamble"]).Value) ? string.Empty : ((MultiLineTextField)form.Fields["preamble"]).Value;
                settings.ShowHeaders = ((BooleanField)form.Fields["showHeaders"]).Value;
                settings.Rows        = string.IsNullOrWhiteSpace(((MultiLineTextField)form.Fields["rows"]).Value) ? string.Empty : ((MultiLineTextField)form.Fields["rows"]).Value;

                // Perform the update
                Update(settings);

                // 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));
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Submits form.
        /// </summary>
        /// <param name="form">View model containing form definition and submitted values.</param>
        /// <returns>Result of form post.</returns>
        public FormResult PostForm(Form form)
        {
            try
            {
                // Check permissions
                _authorizationService.AuthorizeUserForFunction(Functions.UpdateMasterPages);

                // The form result
                FormResult formResult = UpdateMasterPageZone(form);

                // Return result
                return formResult;
            }
            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);
            }
        }
Ejemplo n.º 22
0
        public FormResult PostForm(Form form)
        {
            try
            {
                // The form result
                FormResult formResult = null;

                // Split context into different parts
                string action = form.Context.Split('|')[0];

                // Perform the correct action based on form context
                switch (action)
                {
                case "":
                    formResult = PostUserForm(form);
                    break;

                case "admin":
                    formResult = PostAdminForm(form);
                    break;
                }

                // Return result
                return(formResult);
            }
            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 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));
            }
        }