Exemplo n.º 1
0
        public ResponseDto Save(ProductSaveDto saveDto)
        {
            ResponseDto responseDto = new ResponseDto();

            ProductSaveBo saveBo = new ProductSaveBo()
            {
                Id            = saveDto.Id,
                Name          = saveDto.Name,
                ProductTypeId = saveDto.ProductTypeId,

                PersonId = saveDto.PersonId,

                SalePrice    = saveDto.SalePrice,
                PurhasePrice = saveDto.PurhasePrice,
                CurrencyId   = saveDto.CurrencyId,
                VatRate      = saveDto.VatRate,

                Barcode = saveDto.Barcode,

                Session = Session
            };

            ResponseBo responseBo = productBusiness.Save(saveBo);

            responseDto = responseBo.ToResponseDto();

            return(responseDto);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method looks from external sources.
        /// Please run this only a barcode not found in db.
        /// This method doest not add to person product table but only product table.
        /// </summary>
        /// <param name="barcode"></param>
        /// <returns></returns>
        internal ResponseDto AddFromExternalSource(string barcode, Sessions.Session session, long?shopId)
        {
            ResponseDto responseDto = new ResponseDto();

            try
            {
                BarkodServisSoapClient client      = new BarkodServisSoapClient();
                BarkodSonuc            barkodSonuc = client.BarkodGetir(Stc.BarkodOkuComKey, barcode);

                if (barkodSonuc.HataMesaji != null)
                {
                    responseDto.IsSuccess = false;
                    responseDto.Message   = barkodSonuc.HataMesaji.HataAciklama;

                    return(responseDto);
                }

                ProductSaveBo saveBo = new ProductSaveBo();
                saveBo.Session = session;

                saveBo.Name          = barkodSonuc.UrunBarkod.UrunAd;
                saveBo.ProductTypeId = Enums.ProductTypes.xShopping;

                saveBo.PersonId = shopId;

                saveBo.VatRate = 18;

                saveBo.Barcode = barcode;

                if (barkodSonuc.UrunBarkod.UrunFiyat != null && barkodSonuc.UrunBarkod.UrunFiyat.Length > 0)
                {
                    saveBo.SalePrice    = Convert.ToDecimal(barkodSonuc.UrunBarkod.UrunFiyat[0].UrunFiyat);
                    saveBo.PurhasePrice = saveBo.SalePrice * (decimal)0.8;
                }
                else
                {
                    saveBo.SalePrice    = 10;
                    saveBo.PurhasePrice = 8;
                }

                saveBo.CurrencyId = Enums.Currencies.xTurkishLira;

                saveBo.RefSourceJson = JsonConvert.SerializeObject(barkodSonuc);

                responseDto = productBusiness.Save(saveBo).ToResponseDto();
            }
            catch (Exception ex)
            {
                responseDto = base.SaveExLog(ex, this.GetType(), MethodBase.GetCurrentMethod().Name);
            }
            return(responseDto);
        }
Exemplo n.º 3
0
        public ResponseBo Save(ProductSaveBo 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("@Id", saveBo.Id, DbType.Int64, ParameterDirection.Input);
                    p.Add("@Name", saveBo.Name, DbType.String, ParameterDirection.Input, 255);
                    p.Add("@ProductTypeId", saveBo.ProductTypeId, DbType.Int32, ParameterDirection.Input);

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

                    p.Add("@SalePrice", saveBo.SalePrice, DbType.Decimal, ParameterDirection.Input);
                    p.Add("@PurhasePrice", saveBo.PurhasePrice, DbType.Decimal, ParameterDirection.Input);
                    p.Add("@CurrencyId", saveBo.CurrencyId, DbType.Int32, ParameterDirection.Input);
                    p.Add("@VatRate", saveBo.VatRate, DbType.Decimal, ParameterDirection.Input);

                    p.Add("@Barcode", saveBo.Barcode, DbType.String, ParameterDirection.Input, 50);

                    p.Add("@RefSourceJson", saveBo.RefSourceJson, DbType.String, ParameterDirection.Input, Int32.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("spProductSave", 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);
        }