public ResponseBo <List <PropertyListBo> > GetList(PropertyGetListCriteriaBo criteriaBo) { ResponseBo <List <PropertyListBo> > responseBo = new ResponseBo <List <PropertyListBo> >(); 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("@PropertyGroupId", criteriaBo.PropertyGroupId, 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 <PropertyListBo>("spPropertyList", 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 <PropertyListBo> >(); } return(responseBo); }
//[Admin] public ResponseDto <List <PropertyListDto> > GetList(PropertyGetListCriteriaDto criteriaDto) { PropertyGetListCriteriaBo criteriaBo = new PropertyGetListCriteriaBo() { CaseId = criteriaDto.CaseId, ProductCategoryId = criteriaDto.ProductCategoryId, PersonProductId = criteriaDto.PersonProductId, PropertyGroupId = criteriaDto.PropertyGroupId, Session = Session }; ResponseBo <List <PropertyListBo> > responseBo = propertyBusiness.GetList(criteriaBo); ResponseDto <List <PropertyListDto> > responseDto = responseBo.ToResponseDto <List <PropertyListDto>, List <PropertyListBo> >(); if (responseBo.IsSuccess && responseBo.Bo != null) { responseDto.Dto = new List <PropertyListDto>(); // 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 <PropertyListDto>(); foreach (PropertyListBo itemBo in responseBo.Bo) { responseDto.Dto.Add(new PropertyListDto() { Id = itemBo.PropertyId, Name = itemBo.PropertyName, UrlName = itemBo.PropertyUrlName }); } } else { responseDto.Dto = responseBo.Bo. GroupBy(x => x.GroupId).Select(x => x.First()). Select( x => new PropertyListDto() { Id = x.GroupId, Name = x.GroupName, UrlName = x.GroupUrlName, PropertyList = responseBo.Bo.Where(y => y.GroupId == x.GroupId).Select( y => new PropertyListDto() { Id = y.PropertyId, Name = y.PropertyName, UrlName = y.PropertyUrlName }).ToList() }).ToList(); } } return(responseDto); }