Ejemplo n.º 1
0
        public List <SearchAdditionalChargeResultVM> SearchAdditionalCharges(SearchAdditionalChargeParametersVM model, string sortColumn, string sortDirection)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter {
                    ParameterName = "@Code", Value = model.Code
                },
                new SqlParameter {
                    ParameterName = "@Description", Value = model.Description
                },
                new SqlParameter {
                    ParameterName = "@Price", Value = model.Price
                },
                new SqlParameter {
                    ParameterName = "@PageNum", Value = model.PageNum
                },
                new SqlParameter {
                    ParameterName = "@PageSize", Value = model.PageSize
                },
                new SqlParameter {
                    ParameterName = "@SortColumn", Value = sortColumn
                },
                new SqlParameter {
                    ParameterName = "@SortDirection", Value = sortDirection
                }
            };

            var dt = DALHelper.GetDataTableWithExtendedTimeOut("SearchAdditionalCharges", parameters);

            var charges = new List <SearchAdditionalChargeResultVM>();

            charges = DALHelper.CreateListFromTable <SearchAdditionalChargeResultVM>(dt);

            return(charges);
        }
Ejemplo n.º 2
0
        public ActionResult SearchAdditionalCharges(SearchAdditionalChargeParametersVM model)
        {
            try
            {
                object sortColumn    = "";
                object sortDirection = "";

                if (model.order.Count == 0)
                {
                    sortColumn    = "CreatedOn";
                    sortDirection = "desc";
                }
                else
                {
                    sortColumn    = model.columns[Convert.ToInt32(model.order[0].column)].data ?? (object)DBNull.Value;
                    sortDirection = model.order[0].dir ?? (object)DBNull.Value;
                }

                model.PageSize = Constants.PAGESIZE;
                var charges = additionalChargeRepository.SearchAdditionalCharges(model, Convert.ToString(sortColumn), Convert.ToString(sortDirection));

                int totalRecords = 0;
                var dbRecords    = charges.Select(m => m.TotalCount).FirstOrDefault();

                if (dbRecords != 0)
                {
                    totalRecords = Convert.ToInt32(dbRecords);
                }

                return(Json(new
                {
                    IsSuccess = true,
                    CurrentPage = model.PageNum,
                    PageSize = Constants.PAGESIZE,
                    TotalRecords = totalRecords,
                    data = charges
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "SearchAdditionalCharges");
                return(Json(new { IsSuccess = false, errorMessage = e.Message }));
            }
        }