Exemple #1
0
        public ResponseDto Save(BasketProductSaveDto saveDto)
        {
            ResponseDto responseDto = new ResponseDto();

            BasketProductSaveBo saveBo = new BasketProductSaveBo()
            {
                DebtPersonId   = saveDto.DebtPersonId,
                CreditPersonId = saveDto.CreditPersonId,

                ProductId = saveDto.ProductId,
                Quantity  = saveDto.Quantity,

                CurrencyId = saveDto.CurrencyId,
                IsFastSale = saveDto.IsFastSale,

                OptionIdList         = saveDto.OptionIdList,
                IncludeExcludeIdList = saveDto.IncludeExcludeIdList,

                Session = Session
            };

            ResponseBo responseBo = basketProductBusiness.Save(saveBo);

            responseDto = responseBo.ToResponseDto();

            base.SendNotifyWsToList(responseBo.PersonNotifyList);

            return(responseDto);
        }
        public ResponseBo Save(BasketProductSaveBo saveBo)
        {
            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("@NotifyPersonListJson", dbType: DbType.String, direction: ParameterDirection.Output, size: 1000);

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

                    p.Add("@ProductId", saveBo.ProductId, DbType.Int64, ParameterDirection.Input);
                    p.Add("@Quantity", saveBo.Quantity, DbType.Decimal, ParameterDirection.Input);

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

                    p.Add("@OptionIdListCommaSpr", saveBo.OptionIdList.ToStrSeparated(), DbType.String, ParameterDirection.Input, 1000);
                    p.Add("@IEIdListCommaSpr", saveBo.IncludeExcludeIdList.ToStrSeparated(), DbType.String, ParameterDirection.Input, 1000);

                    p.Add("@ApiSessionId", saveBo.Session.ApiSessionId, DbType.Int64, ParameterDirection.Input);
                    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("spBasketProductSave", p, commandType: CommandType.StoredProcedure);
                    responseBo.Message    = p.Get <string>("@Message");
                    responseBo.IsSuccess  = p.Get <bool>("@IsSuccess");
                    responseBo.ReturnedId = p.Get <long?>("@ReturnedId");

                    string NotifyPersonListJson = p.Get <string>("@NotifyPersonListJson");
                    if (NotifyPersonListJson.IsNotNull())
                    {
                        responseBo.PersonNotifyList = JsonConvert.DeserializeObject <List <PersonNotifyListBo> >(NotifyPersonListJson);
                    }
                }
            }
            catch (Exception ex)
            {
                responseBo = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name, saveBo);
            }

            return(responseBo);
        }