public string PostVote(ReqVote objReq) { string rst = "0"; try { if (!string.IsNullOrWhiteSpace(objReq.postId)) { using (var db = new UnseentalentdbDataContext()) { Vote votedByUser = db.Votes.FirstOrDefault(x => x.UserId == Convert.ToInt64(objReq.userId) && x.VideoId == Convert.ToInt64(objReq.postId)); if (votedByUser == null) { var objNew = new Vote(); objNew.VideoId = Convert.ToInt64(objReq.postId); objNew.UserId = Convert.ToInt64(objReq.userId); objNew.IsVote = objReq.isLike == "True"; objNew.CreatedDate = DateTime.UtcNow; db.Votes.InsertOnSubmit(objNew); } else { votedByUser.IsVote = objReq.isLike == "True"; votedByUser.CreatedDate = DateTime.UtcNow; } db.SubmitChanges(); rst = "1"; } } } catch { } return rst; }
public Response<string> postVote(ReqVote objReq) { var response = new Response<string>(); string rst = ""; try { var objmethod = new UnseenTalentsMethod(); rst = objmethod.PostVote(objReq); if (rst == "1") { response.Create(true, 1, "successfully", rst); } else { response.Create(false, 1, "Invalid request", rst); } } catch (Exception ex) { response.Create(false, -1, Messages.FormatMessage(ex.Message), "0"); } finally { // return response; } return response; }