예제 #1
0
 public ActionResult Create()
 {
     var postView = new PostView
     {
         CurrentLang = CurrentLang.ID
     };
     return View("Edit", postView);
 }
예제 #2
0
 public ActionResult Edit(PostView postView)
 {
     if (ModelState.IsValid)
     {
         var post = (Post)ModelMapper.Map(postView, typeof(PostView), typeof(Post));
         post.CurrentLang = CurrentLang.ID;
         if (post.ID == 0)
         {
             post.UserID = CurrentUser.ID;
             Repository.CreatePost(post);
         }
         else
         {
             Repository.UpdatePost(post);
         }
         TempData["Message"] = "Сохранено!";
         return RedirectToAction("Index");
     }
     return View(postView);
 }