public async Task <IActionResult> Index() { var response = await _votingService.GetAsync(_configuration.GetValue <string>("VotingEndPoint:GetCategories")); ModelVotingView model = new ModelVotingView(); model.CategoryOptions = model.ConstructBookOptions(response.Data != null ? JsonConvert.DeserializeObject <List <ModelCategoryView> >(Convert.ToString(response.Data)) : new List <ModelCategoryView>()); model.CreatedDate = DateTime.Now; model.DueDate = DateTime.Now.AddDays(1); return(View(model)); }
public async Task <BaseResponse> UpdateVoting(ModelVotingView model) { BaseResponse response = new BaseResponse(); using (var dbcxtransaction = await _context.Database.BeginTransactionAsync()) { try { var voting = await _context.MasterVotingProcess.FindAsync(model.VotingProcessId); voting.VotingProcessName = model.VotingProcessName; voting.Description = model.Description; voting.CreatedDate = model.CreatedDate; voting.DueDate = model.DueDate; voting.VotingCategoryId = model.VotingCategoryId; voting.ModifiedDate = DateTime.Now; voting.ModifiedBy = "Admin"; _context.Entry(voting).State = EntityState.Modified; await _context.SaveChangesAsync(); dbcxtransaction.Commit(); response.Code = (int)HttpStatusCode.OK; response.Status = HttpStatusCode.OK.ToString(); response.Message = "Update data success."; } catch (Exception ex) { response.Message = ex.ToString(); response.Code = (int)HttpStatusCode.InternalServerError; response.Status = HttpStatusCode.InternalServerError.ToString(); dbcxtransaction.Rollback(); } } return(response); }
public async Task <BaseResponse> UpdateVoting(ModelVotingView model) { return(await _votingRepository.UpdateVoting(model)); }
public async Task <BaseResponse> DeleteVoting([FromQuery] int votingProcessId) { ModelVotingView model = null; return(await _votingService.PostAsync(_configuration.GetValue <string>("VotingEndPoint:DeleteVoting") + "?votingProcessId=" + votingProcessId, model)); }
public async Task <BaseResponse> UpdateVoting(ModelVotingView model) { return(await _votingService.PostAsync(_configuration.GetValue <string>("VotingEndPoint:UpdateVoting"), model)); }