Exemple #1
0
        public ResponseDto <List <ProductCategoryListDto> > GetList(ProductCategoryGetListCriteriaDto criteriaDto)
        {
            ProductCategoryGetListCriteriaBo criteriaBo = new ProductCategoryGetListCriteriaBo()
            {
                ProductCategoryId = criteriaDto.ProductCategoryId,
                IsUpper           = criteriaDto.IsUpper,

                Session = Session
            };

            ResponseBo <List <ProductCategoryListBo> > responseBo = productCategoryBusiness.GetList(criteriaBo);

            ResponseDto <List <ProductCategoryListDto> > responseDto = responseBo.ToResponseDto <List <ProductCategoryListDto>, List <ProductCategoryListBo> >();

            if (responseBo.IsSuccess && responseBo.Bo != null)
            {
                responseDto.Dto = new List <ProductCategoryListDto>();
                foreach (ProductCategoryListBo itemBo in responseBo.Bo)
                {
                    responseDto.Dto.Add(new ProductCategoryListDto()
                    {
                        Id   = itemBo.Id,
                        Name = itemBo.Name,

                        UrlName = itemBo.UrlName,

                        IsLast = itemBo.IsLast,

                        ParentId = itemBo.ParentId
                    });
                }
            }

            return(responseDto);
        }
        public ResponseBo <List <ProductCategoryListBo> > GetListAdmin(ProductCategoryGetListCriteriaBo criteriaBo)
        {
            ResponseBo <List <ProductCategoryListBo> > responseBo = new ResponseBo <List <ProductCategoryListBo> >();

            try
            {
                using (SqlConnection conn = DbAccess.Connection.GetConn())
                {
                    var p = new DynamicParameters();
                    p.Add("@Message", dbType: DbType.String, direction: ParameterDirection.Output, size: 255);
                    p.Add("@IsSuccess", dbType: DbType.Boolean, direction: ParameterDirection.Output);

                    p.Add("@ParentId", criteriaBo.ProductCategoryId, DbType.Int32, ParameterDirection.Input);

                    p.Add("@MyPersonId", criteriaBo.Session.MyPerson.Id, DbType.Int64, ParameterDirection.Input);
                    p.Add("@OperatorRealId", criteriaBo.Session.RealPerson.Id, DbType.Int64, ParameterDirection.Input);
                    p.Add("@LanguageId", criteriaBo.Session.RealPerson.LanguageId, DbType.Int32, ParameterDirection.Input);

                    responseBo.Bo        = conn.Query <ProductCategoryListBo>("spProductCategoryList", p, commandType: CommandType.StoredProcedure).ToList();
                    responseBo.Message   = p.Get <string>("@Message");
                    responseBo.IsSuccess = p.Get <bool>("@IsSuccess");
                }
            }
            catch (Exception ex)
            {
                responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, criteriaBo).ToResponse <List <ProductCategoryListBo> >();
            }

            return(responseBo);
        }