Esempio n. 1
0
        public async Task <JsonResult> GetDistributors()
        {
            try
            {
                logger.Debug("Search Controller GetDistributors action method is invoked");

                DistributorModel model = new DistributorModel(_unitOfWork);

                List <Distributor> records = await model.GetDistributorsByPageAsync(null, null, string.Empty, string.Empty, string.Empty, string.Empty);

                return(this.Json(records.Select(x => new { Id = x.Id, Name = x.Name }), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                logger.Error("Error while invoking GetDistributors action method: ", ex);
                return(this.Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 2
0
        public async Task <JsonResult> ListAsync(int?page, int?limit, string sortBy, string direction, string code, string name)
        {
            try
            {
                DistributorModel model = new DistributorModel(_unitOfWork);

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

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

                logger.Debug("Distributor Controller List action method is invoked");
                logger.Debug(string.Format("Total {0} distributors 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));
            }
        }