public ResponseBo <List <OrderListBo> > GetList(OrderGetListCriteriaBo criteriaBo)
        {
            ResponseBo <List <OrderListBo> > responseBo = new ResponseBo <List <OrderListBo> >();

            try
            {
                using (SqlConnection conn = DbAccess.Connection.GetConn())
                {
                    var p = new DynamicParameters();
                    base.AddStandartSpParams(ref p, criteriaBo);

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

                    p.Add("@PersonId", criteriaBo.PersonId, DbType.Int64, ParameterDirection.Input);

                    p.Add("@GetIncomings", criteriaBo.GetIncomings, DbType.Boolean, ParameterDirection.Input);
                    p.Add("@GetReturns", criteriaBo.GetReturns, DbType.Boolean, ParameterDirection.Input);
                    p.Add("@OrderStatList", criteriaBo.OrderStatList.ToStrSeparated(), DbType.String, ParameterDirection.Input, 255);

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

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

                    responseBo.Bo        = conn.Query <OrderListBo>("spOrderList", p, commandType: CommandType.StoredProcedure).ToList();
                    responseBo.Message   = p.Get <string>("@Message");
                    responseBo.IsSuccess = p.Get <bool>("@IsSuccess");

                    if (responseBo.IsNotNull() && responseBo.Bo.IsNotNull())
                    {
                        foreach (OrderListBo itemBo in responseBo.Bo)
                        {
                            if (itemBo.CodeListRawJson.IsNotNull())
                            {
                                itemBo.CodeList = JsonConvert.DeserializeObject <List <ProductCodeBo> >(itemBo.CodeListRawJson);
                            }

                            if (itemBo.OptionListRawJson.IsNotNull())
                            {
                                itemBo.OptionList = JsonConvert.DeserializeObject <List <OptionListBo> >(itemBo.OptionListRawJson);
                            }

                            if (itemBo.IncludeExcludeListRawJson.IsNotNull())
                            {
                                itemBo.IncludeExcludeList = JsonConvert.DeserializeObject <List <IncludeExcludeBo> >(itemBo.IncludeExcludeListRawJson);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, criteriaBo).ToResponse <List <OrderListBo> >();
            }

            return(responseBo);
        }
        public ResponseDto <List <OrderListDto> > GetList(OrderGetListCriteriaDto criteriaDto)
        {
            OrderGetListCriteriaBo criteriaBo = new OrderGetListCriteriaBo()
            {
                CaseId = criteriaDto.CaseId,

                PersonId = criteriaDto.PersonId,

                GetIncomings  = criteriaDto.GetIncomings,
                GetReturns    = criteriaDto.GetReturns,
                OrderStatList = criteriaDto.OrderStatList,

                CurrencyId = criteriaDto.CurrencyId,

                PageOffSet = criteriaDto.PageOffSet,

                Session = Session
            };

            ResponseBo <List <OrderListBo> > responseBo = orderBusiness.GetList(criteriaBo);

            ResponseDto <List <OrderListDto> > responseDto = responseBo.ToResponseDto <List <OrderListDto>, List <OrderListBo> >();

            if (responseBo.IsSuccess && responseBo.Bo != null)
            {
                responseDto.Dto = responseBo.Bo.
                                  GroupBy(x => x.Id).Select(x => x.First()).
                                  Select(
                    x => new OrderListDto()
                {
                    Id = x.Id,

                    DebtPersonId       = x.DebtPersonId,
                    DebtPersonFullName = x.DebtPersonFullName,
                    DebtPersonTypeId   = x.DebtPersonTypeId,

                    CreditPersonId       = x.CreditPersonId,
                    CreditPersonFullName = x.CreditPersonFullName,
                    CreditPersonTypeId   = x.CreditPersonTypeId,

                    OrderStatId = x.OrderStatId,
                    CurrencyId  = x.CurrencyId,
                    GrandTotal  = x.GrandTotal,

                    Notes = x.Notes,

                    IsReturn       = x.IsReturn,
                    RelatedOrderId = x.RelatedOrderId,

                    BasketId          = x.BasketId,
                    DeliveryAddressId = x.DeliveryAddressId,

                    ShopId        = x.ShopId,
                    ShopFullName  = x.ShopFullName,
                    ShopStarCount = x.ShopStarCount,
                    ShopStarSum   = x.ShopStarSum,
                    ShopUrlName   = x.ShopUrlName,

                    CommentId     = x.PersonCommentId,
                    IsCommentable = x.IsCommentable,

                    CreateDateNumber = x.CreateDate.ToNumberFromDateTime(),
                    UpdateDateNumber = x.UpdateDate.ToNumberFromDateTimeNull(),

                    Phone = x.Phone,

                    ProductList = responseBo.Bo.Where(y => y.Id == x.Id).Select(
                        y => new OrderProductListDto()
                    {
                        Id         = y.OrderProductId,
                        Quantity   = y.Quantity,
                        UnitPrice  = y.UnitPrice,
                        GrandTotal = y.RowGrandTotal,
                        Notes      = y.RowNotes,

                        ProductId     = y.ProductId,
                        ProductName   = y.ProductName,
                        ProductTypeId = y.ProductTypeId,

                        CategoryId = y.CategoryId,
                        StarCount  = y.StarCount,
                        StarSum    = y.StarSum,

                        PortraitImageUniqueIdStr = base.GetImageName(y.PortraitImageUniqueId, y.PortraitImageFileTypeId),

                        CommentId = y.PersonProductCommentId,

                        CodeList = (from z in y.CodeList
                                    select new ProductCodeDto()
                        {
                            Code = z.Code,
                            ProductCodeTypeId = z.ProductCodeTypeId,
                            ProductId = z.ProductId
                        }).ToList(),

                        OptionList = y.OptionList == null ? null :
                                     (from o in y.OptionList
                                      select new OptionListDto()
                        {
                            Id = o.OptionId,
                            Name = o.OptionName,
                            PriceGap = o.OptionPriceGap
                        }).ToList(),
                        IncludeExcludeList = y.IncludeExcludeList == null ? null :
                                             (from i in y.IncludeExcludeList
                                              select new IncludeExcludeDto()
                        {
                            Id = i.Id,
                            PriceGap = i.PriceGap,
                            Name = i.Name,
                            IsInclude = i.IsInclude
                        }).ToList()
                    }).ToList()
                }).ToList();
            }

            return(responseDto);
        }