Exemplo n.º 1
0
        public ResponseBo SavePersonProduct(PersonProductOptionBo saveBo)
        {
            ResponseBo responseBo = new ResponseBo();

            try
            {
                string optionListJson = null;
                if (saveBo.OptionList != null && saveBo.OptionList.Count() > 0)
                {
                    optionListJson = JsonConvert.SerializeObject(saveBo.OptionList);
                }

                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("@PersonProductId", saveBo.PersonProductId, DbType.Int64, ParameterDirection.Input);
                    p.Add("@OptionListJson", optionListJson, DbType.String, ParameterDirection.Input, int.MaxValue);

                    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);

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

            return(responseBo);
        }
Exemplo n.º 2
0
        public ResponseDto SavePersonProduct(PersonProductOptionDto saveDto)
        {
            ResponseDto responseDto = new ResponseDto();

            PersonProductOptionBo saveBo = new PersonProductOptionBo()
            {
                PersonProductId = saveDto.PersonProductId,
                OptionList      = saveDto.OptionList == null ? null :
                                  (from x in saveDto.OptionList
                                   select new OptionBo()
                {
                    OptionId = x.OptionId,
                    PriceGap = x.PriceGap
                }).ToList(),

                Session = Session
            };

            ResponseBo responseBo = optionBusiness.SavePersonProduct(saveBo);

            responseDto = responseBo.ToResponseDto();

            return(responseDto);
        }