public void IncetrementLikesQuestion(QuestionLike q) { context.Database.ExecuteSqlCommand(String.Format("EXEC dbo.[usp_QuestionsLikesInsert] {0},{1},'{2}','{3}','{4}'", q.QuestionID, q.UserID, q.DateLike.Value.ToString("MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture), q.CreatorIP, q.GUID)); }
public ActionResult Like(int? id) { DB.DAL.User a = Autorizacija.Autorizacija.GetCurrentUser(this.HttpContext); if (a != null) TempData["user"] = a; Question q = null; int Uid = Autorizacija.Autorizacija.GetCurrentUser(this.HttpContext).UserID; string likes_new = ""; if (id.HasValue) { using (DBBL Baza = new DBBL()) { QuestionLike ql = new QuestionLike() { QuestionID = id.Value, UserID = Uid, GUID = Guid.NewGuid(), DateLike = DateTime.Now, CreatorIP = this.Request.GetIpAdresa() }; try { Baza.IncetrementLikesQuestion(ql); } catch (Exception) { return Content("False"); } q = Baza.GetQuestionByID(id.Value); likes_new = q.QuestionLikes.Count.ToString(); } } return Json(new { likes = likes_new, id = id }, JsonRequestBehavior.AllowGet); }