public string ApplyReward(Rewards id) { try { using (WorkBountyDBEntities entities = new WorkBountyDBEntities()) { entities.Configuration.ValidateOnSaveEnabled = false; string remarks = id.Remarks.ToString(); Workitem remark = new Workitem() { WorkitemID = id.WorkItemID, Remarks = id.Remarks }; entities.Workitems.Attach(remark); entities.Entry(remark).Property(u => u.Remarks).IsModified = true; entities.SaveChanges(); } List<WorkItemAssignment> checkUploadedWorkitem = entity.WorkItemAssignments.Where(s => s.WorkItemID == id.WorkItemID && s.UserID == id.UserID).ToList(); foreach (var data in checkUploadedWorkitem) { WorkItemAssignment item = entity.WorkItemAssignments.Where(s => s.WorkItemID == id.WorkItemID && s.UserID == id.UserID).FirstOrDefault(); item.IsRewarded = true; entity.SaveChanges(); } return "Success"; } catch (Exception) { return "Error"; } }
public JsonResult PayReward(Rewards currentUserID) { var getRewardData = workbountyRepo.ApplyReward(currentUserID); if (getRewardData != null) { return Json("Success"); } else { return Json("Error"); } }