private async Task <AjaxResponse> AddCandidate(AddCandidateModel newCandidate) { Tuple <string, bool> response = await _voteDataAppService.AddCandidate(newCandidate.Name, newCandidate.Detail, newCandidate.Image); AjaxResponse ar = new AjaxResponse(); if (response.Item2) { ar.Success = true; ar.Result = response.Item1; } else { ar.Success = false; ar.Error = new ErrorInfo(response.Item1); } return(ar); }
public async Task <AjaxResponse> AddCandidateAsync([FromBody] AddCandidateModel newCandidate) { return(await Task <AjaxResponse> .Run(() => AddCandidate(newCandidate))); }