public ActionResult brandListing([FromBody] DtoBrandListing obj) { var repo = new DapperAdminRepository(); var srv = new SrvBrandListingV1(repo, cache); var dto = new DtoBrandListingResult(); if (!srv.Exec(network, obj, ref dto)) { return(BadRequest(srv.Error)); } return(Ok(dto)); }
public bool Exec(LocalNetwork network, DtoBrandListing request, ref DtoBrandListingResult ret) { try { if (!ValidadeRequest(request)) { return(false); } using (var db = GetConnection(network)) { var tagCache = GetCacheTag(request); var cacheOn = !string.IsNullOrEmpty(network.cacheServer); if (cacheOn) { var result = GetCachedData(tagCache, network.cacheServer, 1); if (result != null) { ret = JsonConvert.DeserializeObject <DtoBrandListingResult>(result); return(true); } } int total = 0; var lst = adminRepository.GetBrands(db, request.tag, (int)request.page, (int)request.pageSize, (int)request.orderBy, ref total); ret.totalRecords = total; ret.results = new List <DtoBrand>(); for (int i = 0; i < lst.Count; i++) { var item = lst[i]; ret.results.Add(new DtoBrand { id = item.id, name = item.stName, }); } if (cacheOn) { var retStr = System.Text.Json.JsonSerializer.Serialize(ret); UpdateCachedData(tagCache, retStr, network.cacheServer, 1); } } return(true); } catch (Exception ex) { Error = new DtoServiceError { message = getLanguage(0, 0), debugInfo = ex.ToString() }; return(false); } }