Exemple #1
0
        public ActionResult Index(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Error"));
            }
            TextDescriptionViewModel textDescription;

            try
            {
                textDescription = Mapper.ToView(tdService.GetEntityById((int)id));
            }
            catch (ArgumentNullException)
            {
                return(RedirectToAction("Index", "Error"));
            }
            if (!textDescription.IsPublished)
            {
                if (!User.Identity.IsAuthenticated)
                {
                    return(RedirectToAction("Index", "Error"));
                }
                else if (User.Identity.Name != userService.GetEntityById(textDescription.AuthorId).Login)
                {
                    return(RedirectToAction("AccessViolation", "Error"));
                }
            }
            textDescription.Texts    = textService.GetTitleTextEntitiesWithoutContent(textDescription.Id).Select(Mapper.ToView);
            textDescription          = ModelHelper.ReadTextDescriptionAdditionInfo(textDescription);
            textDescription.Comments = ModelHelper.ReadCommentsForModel("TextDescription", (int)id);
            return(View(textDescription));
        }
        public ActionResult Create(int titleId)
        {
            var td   = tdService.GetEntityById(titleId);
            var user = userService.GetUserByLogin(User.Identity.Name);

            if (user.Id != td.AuthorId)
            {
                return(RedirectToAction("AccessViolation", "Error"));
            }
            var model = new TextViewModel {
                TitleId = titleId
            };

            return(PartialView(model));
        }