Example #1
0
        public virtual ActionResult Edit(ArticleModel model)
        {
            if (ModelState.IsValid)
            {
                Status status;
                if (model.Update(out status))
                {
                    ModelState.AddModelError("Error", "Successfully updated system article");
                }
                else
                {
                    ModelState.AddModelError("Error", status.Message());
                }
            }
            else
            {
                ModelState.AddModelError("Error", "Please update the required fields");
            }

            return View(model);
        }
        public static ArticleModel GetArticleModel(this Article entity)
        {
            var model = new ArticleModel
            {
                Id = entity.Id,
                IdKey = entity.IdKey,
                Title = entity.Title,
                Description = entity.Description,
                StartDate = entity.Start.ToShortDateString(),
                EndDate = entity.End.ToShortDateString(),
                Author = entity.Author,
                Summary = entity.Summary,
                CategoryId = entity.CategoryId,
                Approved = entity.Approved,
            };

            return model;
        }
        /// <summary>
        /// Creates a entity model used by the ArticlesController.Add method
        /// </summary>
        /// <returns></returns>
        public static ArticleModel GetArticleModelForAdd()
        {
            var model = new ArticleModel();
            Guid userIdKey = ManageUserModelHelper.GetFormsAuthenticationTicket().IdKey();
            
            model.PageTitle = "Holy Angels System Article";
            model.SubTitle = "Add New Article";
            model.UserIdKey = userIdKey;

            model.MetaDescription = "";
            model.MetaKeywords = "";
            model.MetaSubject = "";

            return model;
        }