/// <summary> /// Creates one or more Requests /// </summary> /// <param name="body"></param> /// <returns></returns> public void RequestServiceCreateRequests(RequestPostRequest body) { var path = "/requests"; path = path.Replace("{format}", "json"); var queryParams = new Dictionary <String, String>(); var headerParams = new Dictionary <String, String>(); var formParams = new Dictionary <String, String>(); var fileParams = new Dictionary <String, FileParameter>(); String postBody = null; postBody = ApiClient.Serialize(body); // http body (model) parameter // authentication setting, if any String[] authSettings = new String[] { }; // make the HTTP request IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling RequestServiceCreateRequests: " + response.Content, response.Content); } else if (((int)response.StatusCode) == 0) { throw new ApiException((int)response.StatusCode, "Error calling RequestServiceCreateRequests: " + response.ErrorMessage, response.ErrorMessage); } return; }
public RequestPostResponse Create(RequestPostRequest requestRepost) { var request = Mapper.Map <Request>(requestRepost); request.Id = Guid.NewGuid(); _requestService.Create(request, out var isPostSaved); if (isPostSaved == false) { throw new InternalServerErrorException(CommonConstant.Error.InternalServerError); } var requestDb = _requestService.Include(x => x.Post).Include(x => x.Response).FirstAsync(x => x.Id == request.Id).Result; var postResponse = Mapper.Map <RequestPostResponse>(requestDb); return(postResponse); }
public RequestPostResponse Create([FromBody] RequestPostRequest request) { request.UserId = User.GetUserId(); return(_requestService.Create(request)); }