Пример #1
0
        public IExecutionResult Update(ArticleModifyViewModel model, string currentLoggedUserId)
        {
            if (model.AuthorId == currentLoggedUserId)
            {
                return(base.Update(model));
            }

            return(new ExecutionResult()
            {
                Succeded = false,
                Message = GlobalMessages.NoAccess("article")
            });
        }
Пример #2
0
        public ActionResult Edit(ArticleModifyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                Service.Update(model, HttpContext.User.Identity.GetUserId());

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #3
0
        public ActionResult Create(ArticleModifyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            try
            {
                model.AuthorId = HttpContext.User.Identity.GetUserId();
                var execution = Service.Create(model);
                if (!execution.Succeded)
                {
                    return(View());
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #4
0
        public override IExecutionResult Create(ArticleModifyViewModel model)
        {
            model.PublishDate = DateTime.Now;

            return(base.Create(model));
        }