//Update VotingCard public JsonResult Vote(VotingCardDto votingCardDto) { object result = null; var votingCard = _context.VotingCards .Include("VotingCardLines").Where(v => v.Id == votingCardDto.Id).FirstOrDefault(); if (votingCard == null) { throw new InvalidOperationException(); } //Validate VotingCardVM on server here try { var votingCardLines = VotingCardHelper.ToVotingCardLines(votingCardDto.VotingCardLines); votingCard.Vote(votingCardDto.IsInvalid, votingCardLines); _context.SaveChanges(); var returnedObj = new { AmtAlreadyVoted = votingCard.AmtAlreadyVoted }; result = new { Status = true, Message = "", ReturnedObj = returnedObj }; } catch (Exception ex) { result = new { Status = false, Message = ex.Message }; } return(Json(result, JsonRequestBehavior.AllowGet)); }
//Get VotingCard to input VotingCard (from shareholders' Voting Card) public JsonResult GetVotingCard(int id) { var votingCard = _votingCardSvc.GetVotingCard(id); //For json serialization if (votingCard == null) { return(Json(null, JsonRequestBehavior.AllowGet)); } var votingCardDto = VotingCardHelper.ToVotingCardDto(votingCard); return(Json(votingCardDto, JsonRequestBehavior.AllowGet)); }