public ActionResult SetLikeState(int shareid, bool liked) { int res = 0; Liked like = likedManager.Find(x => x.Share.Id == shareid && x.LikedUser.Id == CurrentSession.User.Id); Share share = shareManager.Find(x => x.Id == shareid); if (like != null && liked == false) { res = likedManager.Delete(like); } else if (like == null && liked == true) { res = likedManager.Insert(new Liked() { LikedUser = CurrentSession.User, Share = share }); } if (res > 0) { if (liked) { share.LikeCount++; } else { share.LikeCount--; } shareManager.Update(share); return(Json(new { hasError = false, errorMessage = string.Empty, result = share.LikeCount })); } return(Json(new { hasError = true, errorMessage = "Beğenme işlemi gerçekleştirilemedi", result = share.LikeCount })); }
public ActionResult Edit(Share share) { ModelState.Remove("CreatedDate"); ModelState.Remove("ModifiedDate"); if (ModelState.IsValid) { Share db_share = shareManager.Find(x => x.ShareId == share.ShareId); db_share.ShareText = share.ShareText; db_share.ShareVideoFileName = share.ShareVideoFileName; db_share.ShareImageFileName = share.ShareImageFileName; shareManager.Update(db_share); return(RedirectToAction("Index")); } return(View(share)); }
public bool Save(ShareEntity share) { _manager.ClearBrokenRuleMessages(); #if !DEBUG using (TransactionScope tran = new TransactionScope()) { #endif bool result = false; if (share.Type == 0) { share.TypeEntity.CreatedBy = share.CreatedBy; share.TypeEntity.CreatedOn = DateTime.Now; result = _manager.InsertType(share.TypeEntity); if (!result) { this.AddBrokenRuleMessages(_manager.BrokenRuleMessages); return(false); } share.Type = share.TypeEntity.ID; } if (share.ID < 1) { result = _manager.Insert(share); } else { result = _manager.Update(share); } if (!result) { this.AddBrokenRuleMessages(_manager.BrokenRuleMessages); return(false); } #if !DEBUG tran.Complete(); } #endif return(true); }