public IList <ClsResult> GetResult(ClsGetResult GetResult) { IList <ClsResult> result = null; try { result = repository.GetResult(GetResult); } catch (Exception e) { throw new Exception("400|" + e.Message, e); } return(result); }
public HttpResponseMessage GetResult([FromUri] ClsGetResult GetResult) { string str = string.Empty; string errMsg = string.Empty, errData = string.Empty; try { ClaimsPrincipal principal = Request.GetRequestContext().Principal as ClaimsPrincipal; var appId = principal.Claims.Where(c => c.Type == "clientId").Single().Value; var orgId = principal.Claims.Where(c => c.Type == "orgId").Single().Value; if (GetResult == null) { errorsList["Error"] = "Data required"; errors.Add(errorsList); this.response = this.Request.CreateResponse(HttpStatusCode.BadRequest, GetResponseBody("error", errors, "info")); } else { if (ModelState.IsValid) { GetResult.appId = appId; GetResult.remoteIP = Request.GetClientIpAddress(); var result = this.iICLabsService.GetResult(GetResult); if (result.Count == 0) { errorsList["Warning"] = "No record found for orderId=" + GetResult.orderId + " and locationId=" + GetResult.locationId; errors.Add(errorsList); this.response = Request.CreateResponse(HttpStatusCode.OK, GetResponseBody("error", errors, "info")); } else { this.response = Request.CreateResponse(HttpStatusCode.OK, GetResponseBody("ok", result)); } } else if (!ModelState.IsValid) { foreach (var state in this.ModelState) { foreach (var error in state.Value.Errors) { errMsg = error.ErrorMessage; errData = state.Key.ToString(); string result = errMsg + "|" + errData.Replace("Vendor.", string.Empty); string[] splitValues = result.Split('|'); for (int i = 0; i < splitValues.Count(); i++) { errorsList[splitValues[i].ToString()] = splitValues[i + 1].ToString(); i++; errors.Add(errorsList); errorsList = new JObject(); } } } this.response = Request.CreateResponse(HttpStatusCode.OK, GetResponseBody("error", errors, "info")); } } } catch (Exception e) { errorsList["Error"] = e.Message; errors.Add(errorsList); return(Request.CreateResponse(HttpStatusCode.BadRequest, GetResponseBody("error", errors, "info"))); } return(this.response); }