internal static GM.Code_Mstr ToGlobal(this Code_Mstr cm) { return(new GM.Code_Mstr() { code_fldname = cm.Code_Fldname, code_value = cm.Code_Value, code_desc = cm.Code_Desc }); }
public IActionResult SearchOEAN([FromQuery] int page, [FromQuery] string search) { try { if (page < 1) { throw new DataException("Page Number must be at least 1 (" + where + ") (ST)"); } if (search.Length == 0) { throw new DataException("Search String can't be BLANK (" + where + ") (ST)"); } int jump, records, maxpages = 1; Code_Mstr cdm = S.ServiceLocator.Instance.CodeMstrService.Get(new Code_Mstr("CONFIGURATION", "JUMP_OBJECT", "")); if (cdm is null) { jump = 50; } else if (!int.TryParse(cdm.Code_Desc, out jump)) { jump = 50; } records = S.ServiceLocator.Instance.GeneralTypeService.SearchEANcnt(search); IEnumerable <GenObjectSearch> objs = null; if (records > 0) { if (records > jump) { maxpages = records / jump; if (records % jump > 0) { maxpages += 1; } } if (page <= maxpages) { objs = S.ServiceLocator.Instance.GeneralTypeService.SearchEAN(page, jump, search); } if (objs != null && objs.OfType <GenObjectSearch>().Count() == 0) { objs = null; } } ObjectDTO odto = new ObjectDTO(records, maxpages, page, jump, objs); return(ApiControllerHelper.SendOk(this, new ApiResult <ObjectDTO>(HttpStatusCode.OK, null, odto), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public IActionResult GetPage(int page) { try { if (page < 1) { throw new DataException("Page Number must be at least 1 (" + where + ") (GETPAGE)"); } int jump, records, maxpages = 1; Code_Mstr cdm = S.ServiceLocator.Instance.CodeMstrService.Get(new Code_Mstr("CONFIGURATION", "JUMP_MUSIC", "")); if (cdm is null) { jump = 50; } else if (!int.TryParse(cdm.Code_Desc, out jump)) { jump = 50; } records = S.ServiceLocator.Instance.GeneralTypeService.IsUsed(1); IEnumerable <SM.Music> mus = null; if (records > 0) { if (records > jump) { maxpages = records / jump; if (records % jump > 0) { maxpages += 1; } } // int pages = S.ServiceLocator.Instance.MusicService.GetPageCount(jump); if (page <= maxpages) { mus = S.ServiceLocator.Instance.MusicService.GetPage(page, jump); } if (mus != null && mus.OfType <SM.Music>().Count() == 0) { mus = null; } } MusicDTO mdto = new MusicDTO(records, maxpages, page, jump, mus); return(ApiControllerHelper.SendOk(this, new ApiResult <MusicDTO>(HttpStatusCode.OK, null, mdto), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }