示例#1
0
        public OperationStatus UpdateStaticContent(StaticContentDetails staticContentDetails)
        {
            OperationStatus status = null;

            try
            {
                Expression <Func <StaticContent, bool> > condition = content => content.TypeID == (int)staticContentDetails.TypeID && content.IsDeleted == false;
                var contentValue = _staticContentRepository.GetItem(condition);
                if (contentValue != null)
                {
                    contentValue.Content          = staticContentDetails.Content;
                    contentValue.ModifiedByID     = staticContentDetails.ModifiedByID;
                    contentValue.ModifiedDatetime = DateTime.UtcNow;
                    _staticContentRepository.Update(contentValue);
                    _staticContentRepository.SaveChanges();
                }
                else
                {
                    status = OperationStatus.CreateFailureStatus(string.Format(CultureInfo.CurrentCulture, Resources.StaticContentTypeNotFound, staticContentDetails.TypeID));
                }
            }
            catch (Exception exception)
            {
                status = OperationStatus.CreateFailureStatus(exception);
            }

            status = status ?? OperationStatus.CreateSuccessStatus();

            return(status);
        }
示例#2
0
        /// <summary>
        /// Gets static content from the DB
        /// </summary>
        /// <param name="staticContentType">static Content Type</param>
        /// <returns>static content object</returns>
        public StaticContentDetails GetStaticContent(StaticContentType staticContentType)
        {
            Expression <Func <StaticContent, bool> > condition = (staticContent) => staticContent.StaticContentType.TypeID == (int)staticContentType && staticContent.IsDeleted == false;
            var content = _staticContentRepository.GetItem(condition);

            var staticContentDetails = new StaticContentDetails();

            Mapper.Map(content, staticContentDetails);

            return(staticContentDetails);
        }
        public ActionResult Save(StaticContentViewModel staticContentViewModel)
        {
            CheckIfSiteAdmin();

            // Make sure staticContentViewModel is not null
            this.CheckNotNull(() => new { staticContentViewModel });
            if (ModelState.IsValid)
            {
                var staticContent = new StaticContentDetails()
                {
                    TypeID       = staticContentViewModel.ContentType,
                    Content      = staticContentViewModel.Content,
                    ModifiedByID = CurrentUserId
                };

                var status = _staticContentService.UpdateStaticContent(staticContent);
                if (!status.Succeeded)
                {
                    throw new Exception(status.ErrorMessage, status.Exception);
                }

                switch (staticContentViewModel.ContentType)
                {
                case (int)StaticContentType.HomePageHelpText:
                    return(RedirectToAction("Index", "Home"));

                case (int)StaticContentType.FAQ:
                    return(RedirectToAction("FAQs", "Home"));

                case (int)StaticContentType.WWTInstall:
                    return(RedirectToAction("InstallWWT", "Home"));

                case (int)StaticContentType.ExcelInstall:
                    return(RedirectToAction("ExcelAddInWelcome", "Home"));

                case (int)StaticContentType.ExcelHelp:
                    return(RedirectToAction("ExcelAddInHelp", "Home"));

                case (int)StaticContentType.LearnMore:
                    return(RedirectToAction("LearnMore", "Home"));

                case (int)StaticContentType.GetStarted:
                    return(RedirectToAction("GetStarted", "Home"));

                case (int)StaticContentType.VisualizingContentinWWT:
                    return(RedirectToAction("VisualizingContentinWWT", "Home"));

                case (int)StaticContentType.Narwhal:
                    return(RedirectToAction("Narwhal", "Home"));

                case (int)StaticContentType.WWTAddinForExcel:
                    return(RedirectToAction("WWTAddinForExcel", "Home"));

                default:
                    return(RedirectToAction("Index", "Admin"));
                }
            }
            else
            {
                // In case of any validation error stay in the same page.
                staticContentViewModel.Content = Server.HtmlDecode(staticContentViewModel.Content);
                return(View("Save", staticContentViewModel));
            }
        }
示例#4
0
 public async Task <OperationStatus> UpdateStaticContentAsync(StaticContentDetails staticContentDetails)
 {
     return(UpdateStaticContent(staticContentDetails));
 }
示例#5
0
 public Task <OperationStatus> UpdateStaticContentAsync(StaticContentDetails staticContentDetails)
 {
     return(Task.FromResult(UpdateStaticContent(staticContentDetails)));
 }