Exemplo n.º 1
0
 public JsonResult AddCommet(BlogTextItemViewModel model)
 {
     using (var db = new ApplicationDbContext())
     {
         if (model.commet.eMail == null || model.commet.commet == null || model.commet.Name == null)
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         else
         {
             db.Commets.Add(model.commet);
             db.SaveChanges();
             return(Json(true, JsonRequestBehavior.AllowGet));
         }
     }
 }
Exemplo n.º 2
0
        public ActionResult Text(int id)
        {
            BlogTextItemViewModel model = new BlogTextItemViewModel();

            using (var db = new ApplicationDbContext())
            {
                model.text = db.Texts.Include("Admin").Where(t => t.Id == id).FirstOrDefault();

                if (model != null)
                {
                    ViewBag.Error = null;
                    return(View(model));
                }
                else
                {
                    ViewBag.Error = "Yazı bulunamadı";
                    return(View());
                }
            }
        }