public ActionResult MakaleDetay(MakaleDetayViewModel model) { MakaleDetayViewModel mdvm = new MakaleDetayViewModel(); Comment yeniYorum = new Comment(); yeniYorum.ArticleId = model.Makale.Id; if (!string.IsNullOrEmpty(model.Yorum.Content)) { yeniYorum.Content = model.Yorum.Content; } else { mdvm.Makale = repoM.GetById(model.Makale.Id); mdvm.Yorum = new Comment(); mdvm.Yorumlar = mdvm.Makale.Comments.ToList(); return(View(mdvm)); } yeniYorum.UserId = HttpContext.User.Identity.GetUserId(); if (repoC.Add(yeniYorum)) { return(Redirect("/Makale/MakaleDetay/" + model.Makale.Id)); } mdvm.Makale = repoM.GetById(model.Makale.Id); mdvm.Yorum = new Comment(); mdvm.Yorumlar = mdvm.Makale.Comments.ToList(); return(View(mdvm)); }
public ActionResult MakaleDetay(int Id) { MakaleDetayViewModel mdvm = new MakaleDetayViewModel(); mdvm.Makale = repoM.GetById(Id); mdvm.Yorum = new Comment(); mdvm.Yorumlar = mdvm.Makale.Comments.ToList(); return(View(mdvm)); }
public ActionResult MakaleDetay(MakaleDetayViewModel model) { Comment yeniYorum = new Comment(); yeniYorum.ArticleId = model.Makale.Id; yeniYorum.Content = model.Yorum.Content; //yeniYorum.UserId = HttpContext.User.Identity.GetUserId(); //aktif kullanıcının id sini alırız cookielerden yeniYorum.UserId = "55b5fccd-fbd5-4f3a-9fc0-b4b0714cc96d"; if (repoC.Add(yeniYorum)) { return(RedirectToAction("Index")); } return(View()); }