// POST api/<controller> public async Task <HttpResponseMessage> Post(JObject objData) { dynamic jsonData = objData; List <Reason> postReasons = new List <Reason>(); JArray reasonsJsonArray = jsonData.reasons; JObject issueJson = jsonData.issue; Issue toAddIssue = issueJson.ToObject <Issue>(); toAddIssue.State = 1; toAddIssue.MSTeamId = jsonData.teamId.Value; foreach (var item in reasonsJsonArray) { var reason = item.ToObject <Reason>(); reason.State = 1; if (!string.IsNullOrEmpty(reason.Name)) { postReasons.Add(reason); } } await IssuesService.InsertItemAsync(toAddIssue); foreach (var reason in postReasons) { reason.Issue = toAddIssue; await ReasonsService.InsertItemAsync(reason); } return(ToJson(new { issueId = toAddIssue.Id })); }
public async Task <HttpResponseMessage> Post(JObject objData) { dynamic jsonData = objData; JObject reason = jsonData.reason; var toAddReason = reason.ToObject <Reason>(); await ReasonsService.InsertItemAsync(toAddReason); return(ToJson(new { reasonId = toAddReason.Id })); }