public async Task <object> AddFeedResponse([FromBody] AddFeedResponse addFeedResponse) { bool result = true; string error = string.Empty; FeedResponse feedResponse = new FeedResponse(); var id = addFeedResponse.UserId; DateTimeOffset timestamp = DateTimeOffset.Now; try { feedResponse = _feedResponseRepository.AddFeedResponse(id, addFeedResponse.FeedId, addFeedResponse.Response, timestamp); } catch (Exception ex) { result = false; error = ex.Message; } return(new SingleResponse <FeedResponse> { Message = error, DidError = !result, ErrorMessage = error, Token = string.Empty, Model = feedResponse }); }
public async Task <JsonResult> AddFeedResponse(int feedId, int feedResponse) { try { AddFeedResponse addFeedResponse = new AddFeedResponse(); addFeedResponse.UserId = HttpContext.Session.GetObject(StorageType.UserId).ToString();//LocalStorageExtensions.Get(StorageType.UserId); addFeedResponse.FeedId = feedId; addFeedResponse.Response = feedResponse; string response = await APICallerExtensions.APICallAsync("Feed/AddFeedResponse", addFeedResponse, false, HttpContext.Session.GetObject(StorageType.Token).ToString()); if (response.ToLower().Contains("exception:")) { ModelState.AddModelError(string.Empty, response); return(Json(new { result = false, error = response })); } var content = JsonConvert.DeserializeObject <SingleResponse <FeedResponse> >(response); if (!content.DidError) { return(Json(new { content.Model, })); } else { return(Json(new { result = false, error = content.ErrorMessage })); } } catch (Exception ex) { return(Json(new { result = false, error = ex.Message })); } }