Exemple #1
0
 public JsonResult Ekle(Yorum y)
 {
     try
     {
         _yorumRepository.Insert(y);
         _yorumRepository.Save();
         return(Json(new ResultJson {
             Success = true, Message = "Yorumunuz eklendi"
         }));
     }
     catch (Exception ex)
     {
         return(Json(new ResultJson {
             Success = false, Message = "Bir hata oluştu"
         }));
     }
 }
 public ActionResult Ekle(Yorum yorum)
 {
     try
     {
         _yorumRepository.Insert(yorum);
         _yorumRepository.Save();
         return(Json(new ResultJson {
             Success = true, Message = "Blog ekleme işleminiz başarılı."
         }));
     }
     catch (Exception ex)
     {
         return(Json(new ResultJson {
             Success = true, Message = "Blog işlemi sırasında bir hata oluştu."
         }));
     }
 }
        public JsonResult YorumYap(yorum yorum_, string yorum, int MakaleID)
        {
            var sessionControl = HttpContext.Session["ID"];

            if (yorum == null)
            {
                return(Json(new ResultJson {
                    Success = true, Message = "Yorum Eklerken Hata Oluştu !"
                }, JsonRequestBehavior.AllowGet));
            }

            var ipAddress = string.Empty;

            if (HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
            {
                ipAddress = HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
            }
            else if (HttpContext.Request.ServerVariables["HTTP_CLIENT_IP"] != null && HttpContext.Request.ServerVariables["HTTP_CLIENT_IP"].Length != 0)
            {
                ipAddress = HttpContext.Request.ServerVariables["HTTP_CLIENT_IP"];
            }
            else if (HttpContext.Request.UserHostAddress.Length != 0)
            {
                ipAddress = HttpContext.Request.UserHostName;
            }



            _yorumRepository.Insert(new yorum
            {
                KullaniciID = Convert.ToInt32(sessionControl),
                MakaleID    = MakaleID,
                Icerik      = yorum,
                Tarih       = DateTime.Now.ToLocalTime().ToString(),
                Onay        = false,
                Ip          = ipAddress
            });
            _yorumRepository.Save();
            return(Json(new ResultJson {
                Success = false, Message = "Yorum Başarıyla Eklenmiştir. Lütfen Editör Onayını Bekleyiniz !"
            }, JsonRequestBehavior.AllowGet));
        }