public static ArticleViewModel ToMvcViewArticle(this ArticleEntity model) { var articleViewModel = new ArticleViewModel() { Content = model.Content, Id = model.Id, ImagePath = model.ImagePath, TimeAdded = model.DateAdded, Title = model.Name, Author = model.Author, BlogId = model.BlogId, Views = model.Viewed }; if (!string.IsNullOrEmpty(model.Tags)) { articleViewModel.Tags = new List<Tag>(); var tags = model.Tags.Split(','); foreach (var tag in tags) articleViewModel.Tags.Add(new Tag(tag)); } return articleViewModel; }
public ActionResult Edit(ArticleViewModel model) { model.Tags = (ICollection<Tag>)TempData["Tags"]; _articleService.UpdateArticle(model.ToArticleEntity()); return RedirectToAction("Blogs", "Blog"); }