public async Task <ActionResult <Sales> > GetAll(StdCollectionInputs sci) { if (!InGood <Sale>(sci)) { return(BadRequest(ErrorResponse)); } try { return(await _service.GetAll(sci)); } catch (Exception ex) { var msg = ex.Message; return(StatusCode(500, ex)); } }
public async Task <ActionResult <MasterMaps> > GetAll(StdCollectionInputs sci) { if (!InGood <MasterMap>(sci)) { return(BadRequest(ErrorResponse)); } try { return(await _service.GetAll(sci)); } catch (Exception ex) { // new ServerError(Request, sci.Route, ex); } return(null); }
internal bool InGood <T>(StdCollectionInputs sci) { InGoodBase <T>(sci); sci.Sort = ""; if (sci.SortParameters != null && sci.SortParameters.Count > 0) { string[] inEls = sci.Sort.Trim().TrimStart('[').TrimEnd(']').Split(','); foreach (var sortEl in sci.SortParameters) { string realField = new Models.Helpers.FindRealName().FromJson <T>(sortEl.Column); if (realField == "") { ErrorResponse.Errors.Add ( $"{sci.Route} : Invalid sort parameter - {sortEl.Column}" ); } sci.Sort += !sortEl.Desc ? $"{realField}," : $"{realField}:desc,"; } sci.Sort = sci.Sort.TrimEnd(","[0]); } if (sci.Sort == "") { sci.Sort = "createdt:desc"; } return(ErrorResponse.Success); }