Example #1
0
        public async Task <JsonResult> ListAsync(int?page, int?limit, string sortBy, string direction, string code, string name)
        {
            try
            {
                BrandModel model = new BrandModel(_unitOfWork);

                List <Brand> records = await model.GetBrandsByPageAsync(page, limit, sortBy, direction, code, name);

                int total = await model.GetTotalBrandsAsync(page, limit, sortBy, direction, code, name);

                logger.Debug("Brand Controller List action method is invoked");
                logger.Debug(string.Format("Total {0} brands are found and {1} is returned", total, records.Count()));

                return(this.Json(new { records, total }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                logger.Error("Error while invoking List action method: ", ex);
                return(this.Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }