public void FromDto(ProductVolumeDiscountDTO dto)
        {
            if (dto == null) return;

            this.Amount = dto.Amount;
            this.StoreId = dto.StoreId;
            this.Bvin = dto.Bvin ?? string.Empty;
            this.DiscountType = (ProductVolumeDiscountType)((int)dto.DiscountType);
            this.LastUpdated = dto.LastUpdated;
            this.ProductId = dto.ProductId ?? string.Empty;
            this.Qty = dto.Qty;
        }	
        //DTO
        public ProductVolumeDiscountDTO ToDto()
        {
            ProductVolumeDiscountDTO dto = new ProductVolumeDiscountDTO();

            dto.Amount = this.Amount;
            dto.StoreId = this.StoreId;
            dto.Bvin = this.Bvin;
            dto.DiscountType = (ProductVolumeDiscountTypeDTO)((int)this.DiscountType);
            dto.LastUpdated = this.LastUpdated;
            dto.ProductId = this.ProductId;
            dto.Qty = this.Qty;
            
            return dto;
        }
Example #3
0
        private void MigrateProductVolumePrices(string bvin)
        {
            wl(" - Migrating Volume Prices...");

            data.bvc2004Entities db = new data.bvc2004Entities(EFConnString(settings.SourceConnectionString()));
            Api proxy = GetBV6Proxy();

            var itemMain = db.bvc_Product.Where(y => y.ID == bvin).FirstOrDefault();
            if (itemMain == null) return;

            var items = db.bvc_ProductVolumeDiscounts.Where(y => y.ProductID == bvin);
            if (items == null) return;
            foreach (data.bvc_ProductVolumeDiscounts item in items)
            {
                ProductVolumeDiscountDTO v = new ProductVolumeDiscountDTO();

                v.Bvin = item.ProductID;

                v.Amount = (decimal)item.Price;
                v.DiscountType = ProductVolumeDiscountTypeDTO.Amount;

                v.LastUpdated = DateTime.UtcNow;
                v.ProductId = item.ProductID;
                v.Qty = item.Qty;

                wl("Discount for qty: " + v.Qty + " [" + v.Bvin + "]");
                var res = proxy.ProductVolumeDiscountsCreate(v);
                if (res != null)
                {
                    if (res.Errors.Count > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                }
                else
                {
                    wl("FAILED! EXCEPTION!");
                }
            }
        }
Example #4
0
        private void MigrateProductVolumePrices(string bvin)
        {
            wl(" - Migrating Volume Prices...");

            data.BV53Entities db = new data.BV53Entities(EFConnString(settings.SourceConnectionString()));
            Api proxy = GetBV6Proxy();

            var items = db.bvc_ProductVolumeDiscounts.Where(y => y.ProductID == bvin);
            if (items == null) return;
            foreach (data.bvc_ProductVolumeDiscounts item in items)
            {
                ProductVolumeDiscountDTO v = new ProductVolumeDiscountDTO();
                v.Amount = item.Amount;
                v.Bvin = item.bvin;
                switch (item.DiscountType)
                {
                    case 1:
                        v.DiscountType = ProductVolumeDiscountTypeDTO.Percentage;
                        break;
                    case 2:
                        v.DiscountType = ProductVolumeDiscountTypeDTO.Amount;
                        break;
                }
                v.DiscountType = (ProductVolumeDiscountTypeDTO)item.DiscountType;
                v.LastUpdated = item.LastUpdated;
                v.ProductId = item.ProductID;
                v.Qty = item.Qty;

                wl("Discount for qty: " + v.Qty + " [" + v.Bvin + "]");
                var res = proxy.ProductVolumeDiscountsCreate(v);
                if (res != null)
                {
                    if (res.Errors.Count > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                }
                else
                {
                    wl("FAILED! EXCEPTION!");
                }
            }
        }
Example #5
0
 public ApiResponse<ProductVolumeDiscountDTO> ProductVolumeDiscountsUpdate(ProductVolumeDiscountDTO item)
 {
     ApiResponse<ProductVolumeDiscountDTO> result = new ApiResponse<ProductVolumeDiscountDTO>();
     result = RestHelper.PostRequest<ApiResponse<ProductVolumeDiscountDTO>>(this.fullApiUri + "productvolumediscounts/" + Enc(item.Bvin) + "?key=" + Enc(key), MerchantTribe.Web.Json.ObjectToJson(item));
     return result;
 }