public JsonResult VoteVideo(int id, int points) { try {//id için tanımlı olan Article kaydına points kadar puan ekleyelim (TotalPoints) if (Session["HasVoted_" + id] == null || (bool)Session["HasVoted_" + id] != true) { OylamaRep rep = new OylamaRep(); Oylama o = new Oylama(); VideoRep vRep = new VideoRep(); Video selected = vRep.GetById(id); if (selected.TotalRate.HasValue) { selected.TotalRate = selected.TotalRate.Value + points; } else { selected.TotalRate = points; } vRep.Update(selected); Session["HasVoted_" + id] = true; return(Json("Thank you for voting")); } else { return(Json("you can't vote again!")); } } catch (Exception ex) { return(Json("A problem has occured - " + ex.Message)); } }
// GET: Video public ActionResult Detail(int id) { var vRep = new VideoRep(); Video v = vRep.GetById(id); v.VideoGoruntulenmeSayisi++; new VideoRep().Update(v); return(View(v)); }
public ActionResult Duzenle(Video duzenlenenvideo) { var vRep = new VideoRep(); var eski = vRep.GetById(duzenlenenvideo.VideoID); eski.VideoURL = duzenlenenvideo.VideoURL; eski.Aciklama = duzenlenenvideo.Aciklama; eski.IzlenmeSayisi = duzenlenenvideo.IzlenmeSayisi; eski.EklenmeTarihi = duzenlenenvideo.EklenmeTarihi; eski.Baslik = duzenlenenvideo.Baslik; eski.KisaAciklama = duzenlenenvideo.KisaAciklama; if (ModelState.IsValid) { vRep.Update(eski); } return(View(duzenlenenvideo)); }