public ResponseBo <PersonProductProfileBo> GetProfile(PersonProductProfileGetCriteriaBo criteriaBo)
        {
            if (criteriaBo.CaseId == 0 && (criteriaBo.PersonUrlName.IsNull() || criteriaBo.PersonUrlName.Trim().Length > 50))
            {
                return(new ResponseBo <PersonProductProfileBo>()
                {
                    IsSuccess = false,
                    Message = Stc.GetDicValue("xNoShopFound", criteriaBo.Session.RealPerson.LanguageId)
                });
            }
            else if (criteriaBo.CaseId == 1 && criteriaBo.PersonProductId.IsNull())
            {
                return(new ResponseBo <PersonProductProfileBo>()
                {
                    IsSuccess = false,
                    Message = Stc.GetDicValue("xInvalidData", criteriaBo.Session.RealPerson.LanguageId)
                });
            }

            ResponseBo <PersonProductProfileBo> responseBo = new ResponseBo <PersonProductProfileBo>();

            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("@PersonUrlName", criteriaBo.PersonUrlName, DbType.String, ParameterDirection.Input, 50);
                    p.Add("@ProductCode", criteriaBo.ProductCode, DbType.String, ParameterDirection.Input, 50);

                    p.Add("@PersonProductId", criteriaBo.PersonProductId, DbType.Int64, 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 <PersonProductProfileBo>("spPersonProductProfileGet", p, commandType: CommandType.StoredProcedure).FirstOrDefault();
                    responseBo.Message   = p.Get <string>("@Message");
                    responseBo.IsSuccess = p.Get <bool>("@IsSuccess");

                    if (responseBo.Bo != null)
                    {
                        if (responseBo.Bo.CodeListRawJson.IsNotNull())
                        {
                            responseBo.Bo.CodeList = JsonConvert.DeserializeObject <List <ProductCodeBo> >(responseBo.Bo.CodeListRawJson);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, null).ToResponse <PersonProductProfileBo>();
            }

            return(responseBo);
        }
Exemple #2
0
        public ResponseBo SaveOrderArea(ShopOrderAreaBo saveBo)
        {
            if (saveBo == null || saveBo.SubList == null || saveBo.SubList.Count == 0)
            {
                return(new ResponseBo()
                {
                    IsSuccess = false,
                    Message = Stc.GetDicValue("xInvalidData", saveBo.Session.RealPerson.LanguageId)
                });
            }

            ResponseBo responseBo = new ResponseBo();

            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("@ReturnedId", dbType: DbType.Int64, direction: ParameterDirection.Output);

                    p.Add("@Id", saveBo.Id, DbType.Int64, ParameterDirection.Input);

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

                    p.Add("@AddressBoundaryId", saveBo.AddressBoundaryId, DbType.Int32, ParameterDirection.Input);
                    p.Add("@AddressCountryId", saveBo.AddressCountryId, DbType.Int32, ParameterDirection.Input);
                    p.Add("@AddressStateId", saveBo.AddressStateId, DbType.Int32, ParameterDirection.Input);
                    p.Add("@AddressCityId", saveBo.AddressCityId, DbType.Int32, ParameterDirection.Input);
                    p.Add("@AddressDistrictId", saveBo.AddressDistrictId, DbType.Int32, ParameterDirection.Input);

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

                    p.Add("@SubListRawJson", JsonConvert.SerializeObject(saveBo.SubList), DbType.String, ParameterDirection.Input, 4000);

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

                    var user = conn.Execute("spPersonOrderAreaSave", p, commandType: CommandType.StoredProcedure);
                    responseBo.Message    = p.Get <string>("@Message");
                    responseBo.IsSuccess  = p.Get <bool>("@IsSuccess");
                    responseBo.ReturnedId = p.Get <long?>("@ReturnedId");
                }
            }
            catch (Exception ex)
            {
                responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, saveBo);
            }

            return(responseBo);
        }