Exemple #1
0
        public ActionResult Edit(PostViewModel postViewModel)
        {
            var postToUpdate = this.postService.GetBy(postViewModel.Id);

            if (postToUpdate.FriendlyUrl == postViewModel.FriendlyUrl)
            {
                this.ModelState["friendlyUrl"].Errors.Clear();
            }

            this.tagService.UpdatePostTags(postToUpdate, postViewModel.GetTagsAsStrings());
            this.TryUpdateModel(postToUpdate);

            if (this.ModelState.IsValid)
            {
                this.postService.Update();
                return(this.RedirectToAction(Actions.Index));
            }

            return(this.View(postViewModel));
        }