public ResponseBo <List <OptionListBo> > GetList(OptionGetListCriteriaBo criteriaBo)
        {
            ResponseBo <List <OptionListBo> > responseBo = new ResponseBo <List <OptionListBo> >();

            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("@CaseId", criteriaBo.CaseId, DbType.Int32, ParameterDirection.Input);

                    p.Add("@ProductCategoryId", criteriaBo.ProductCategoryId, DbType.Int32, ParameterDirection.Input);
                    p.Add("@PersonProductId", criteriaBo.PersonProductId, DbType.Int64, ParameterDirection.Input);
                    p.Add("@OptionGroupId", criteriaBo.OptionGroupId, 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 <OptionListBo>("spOptionList", 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 <OptionListBo> >();
            }

            return(responseBo);
        }
        public ResponseDto <List <OptionListDto> > GetList(OptionGetListCriteriaDto criteriaDto)
        {
            OptionGetListCriteriaBo criteriaBo = new OptionGetListCriteriaBo()
            {
                CaseId = criteriaDto.CaseId,

                ProductCategoryId = criteriaDto.ProductCategoryId,
                PersonProductId   = criteriaDto.PersonProductId,
                OptionGroupId     = criteriaDto.OptionGroupId,

                Session = Session
            };

            ResponseBo <List <OptionListBo> > responseBo = optionBusiness.GetList(criteriaBo);

            ResponseDto <List <OptionListDto> > responseDto = responseBo.ToResponseDto <List <OptionListDto>, List <OptionListBo> >();

            if (responseBo.IsSuccess && responseBo.Bo != null)
            {
                responseDto.Dto = new List <OptionListDto>();

                // CaseId: 0: get list by category, 1: get list by person product, 2: get list by group.
                if (criteriaDto.CaseId == 2)
                {
                    responseDto.Dto = new List <OptionListDto>();
                    foreach (OptionListBo itemBo in responseBo.Bo)
                    {
                        responseDto.Dto.Add(new OptionListDto()
                        {
                            Id      = itemBo.OptionId,
                            Name    = itemBo.OptionName,
                            UrlName = itemBo.OptionUrlName,

                            PriceGap = itemBo.OptionPriceGap
                        });
                    }
                }
                else
                {
                    responseDto.Dto = responseBo.Bo.
                                      GroupBy(x => x.GroupId).Select(x => x.First()).
                                      Select(
                        x => new OptionListDto()
                    {
                        Id         = x.GroupId,
                        Name       = x.GroupName,
                        UrlName    = x.GroupUrlName,
                        OptionList = responseBo.Bo.Where(y => y.GroupId == x.GroupId).Select(
                            y => new OptionListDto()
                        {
                            Id      = y.OptionId,
                            Name    = y.OptionName,
                            UrlName = y.OptionUrlName,

                            PriceGap = y.OptionPriceGap
                        }).ToList()
                    }).ToList();
                }
            }

            return(responseDto);
        }