// POST api/<controller> public async Task <HttpResponseMessage> Post(JObject objData) { dynamic jsonData = objData; JArray issueMetrics = jsonData.issueMetrics; var toAddIssueMetrics = issueMetrics.Select(im => im.ToObject <IssueMetric>()).ToList(); JArray reasonMetricArrays = jsonData.reasonMetrics; var toAddReasonMetrics = reasonMetricArrays.Select(rmArray => { return(rmArray.Select(rm => rm.ToObject <ReasonMetric>()).ToList()); }).ToList(); await IssuesService.UpdateItemAsync(toAddIssueMetrics.First().Issue); toAddIssueMetrics.ForEach(async issueMetric => { if (issueMetric.MetricValues.HasValue) { if (issueMetric.Id == 0) { await IssueMetricsService.InsertItemAsync(issueMetric); } else { await IssueMetricsService.UpdateItemAsync(issueMetric); } } }); toAddReasonMetrics.ForEach(async reasonMetricList => { await ReasonsService.UpdateItemAsync(reasonMetricList.First().Reason); }); toAddReasonMetrics.ForEach(reasonMetricList => { reasonMetricList.ForEach(async reasonMetric => { if (reasonMetric.ReasonMetricValues.HasValue) { if (reasonMetric.Id == 0) { await ReasonMetricsService.InsertItemAsync(reasonMetric); } else { await ReasonMetricsService.UpdateItemAsync(reasonMetric); } } }); }); return(ToJson(new { success = true })); }
public async Task <HttpResponseMessage> EditReason(JObject objData) { dynamic jsonData = objData; JObject reason = jsonData.reason; var toEditReason = reason.ToObject <Reason>(); await ReasonsService.UpdateItemAsync(toEditReason); return(ToJson(new { issueId = toEditReason.Id })); }