public async Task RemoveAsync(ProductRef product)
        {
            BlobClient blob = await this.OpenBlobClient(product);

            if ((await blob.ExistsAsync()))
            {
                await blob.DeleteAsync();
            }
        }
 public CertainValueCertainProductDiscount CreateCertainValueCertainProductDiscount(ProductRef productRef, int productQuantity, decimal certainValue, DateTime effectiveDate, DateTime endDate)
 {
    var cvcp = new CertainValueCertainProductDiscount(Guid.NewGuid())
     {
         InitialValue = certainValue
     };
     
     cvcp.CertainValueCertainProductDiscountItems.Add(new CertainValueCertainProductDiscount.CertainValueCertainProductDiscountItem(Guid.NewGuid())
     {
         Product = new ProductRef { ProductId = productRef.ProductId },
         EffectiveDate = effectiveDate,
         EndDate = endDate,
         Quantity = productQuantity,
         CertainValue = certainValue,
         _Status = EntityStatus.New
     });
     return cvcp;
 }
        public async Task <Image> TryReadAsync(ProductRef product)
        {
            BlobClient blob = await this.OpenBlobClient(product);

            if (!(await blob.ExistsAsync()))
            {
                return(null);
            }

            using BlobDownloadInfo download = await blob.DownloadAsync();

            try
            {
                return(Image.FromStream(download.Content));
            }
            catch { }
            return(null);
        }
 public CustomerDiscount CreateCustomerDiscount(CostCentreRef outletId, ProductRef productId, decimal discountRate,DateTime effectiveDate)
 {
     if (effectiveDate > DateTime.Now)
         throw new ArgumentException("Invalid effective date, must be in the past");
     if (productId.ProductId == Guid.Empty)
         throw new ArgumentException("Invalid product");
     if (outletId.Id == Guid.Empty)
         throw new ArgumentException("Invalid outlet");
     CustomerDiscount cDiscount = new CustomerDiscount(Guid.NewGuid())
     {
         Outlet = new CostCentreRef {Id=outletId.Id  },
          Product= new ProductRef {ProductId=productId.ProductId},
        
     };
     cDiscount.CustomerDiscountItems.Add(new CustomerDiscount.CustomerDiscountItem(Guid.NewGuid())
     {
          EffectiveDate=effectiveDate,
          DiscountRate=discountRate
     });
     return cDiscount;
 }
 public FreeOfChargeDiscount CreateFreeOfChargeDiscount(ProductRef parentProduct, ProductRef freeOfChargeProduct, int parentProductQuantity, int freeOfChargeProductQuantity, DateTime effectiveDate)
 {
     if (effectiveDate > DateTime.Now)
         throw new ArgumentException("Invalid effective date, must be in the past");
     if (parentProduct.ProductId == 0)
         throw new ArgumentException("Invalid product");
     if (freeOfChargeProduct.ProductId == 0)
         throw new ArgumentException("Invalid product");
     FreeOfChargeDiscount foc = new FreeOfChargeDiscount(0)
     {
         ProductRef = new ProductRef { ProductId=parentProduct.ProductId }
     };
     foc.FreeOfChargeDiscountItems.Add(new FreeOfChargeDiscount.FreeOfChargeDiscountItem(0)
  {
      ParentProductQuantity = parentProductQuantity,
      FreeOfChargeQuantity = freeOfChargeProductQuantity,
      FreeOfChargeProduct = new ProductRef { ProductId=freeOfChargeProduct.ProductId},
       EffectiveDate=effectiveDate
  });
     return foc;
 }
        public ProductGroupDiscount CreateProductGroupDiscount(DiscountGroup DiscountGroup,ProductRef ProductRef, decimal discountRate, DateTime effectiveDate, DateTime endDate, bool isQuantity,decimal quantity)
       {
           
           if (ProductRef.ProductId == Guid.Empty)
               throw new ArgumentException("Invalid product");
           if (DiscountGroup.Id == Guid.Empty)
               throw new ArgumentException("Invalid outlet");
           ProductGroupDiscount pgd = new ProductGroupDiscount(Guid.NewGuid())
           {
               GroupDiscount = new DiscountGroup (DiscountGroup.Id)
           };

            pgd.Product = new ProductRef {ProductId = ProductRef.ProductId};
            pgd.DiscountRate = discountRate;
            pgd.EffectiveDate = effectiveDate;
            pgd.EndDate = endDate;
            pgd.IsByQuantity = isQuantity;
            pgd.Quantity = quantity;
            pgd._Status = EntityStatus.New;
       
           return pgd;
        }
 public PromotionDiscount CreateFreeOfChargeDiscount(ProductRef parentProduct, Guid? freeOfChargeProduct, int parentProductQuantity, int? freeProductQuantity, DateTime effectiveDate, decimal DiscountRate, DateTime endDate)
  {
      
      if (parentProduct.ProductId == Guid.Empty)
          throw new ArgumentException("Invalid product");
      //if (freeOfChargeProduct.ProductId == 0)
      //    throw new ArgumentException("Invalid product");
      PromotionDiscount foc = new PromotionDiscount(Guid.NewGuid())
      {
          ProductRef = new ProductRef { ProductId=parentProduct.ProductId }
      };
      foc.PromotionDiscountItems.Add(new PromotionDiscount.PromotionDiscountItem(Guid.NewGuid())
      {
          ParentProductQuantity = parentProductQuantity,
          FreeOfChargeQuantity = freeProductQuantity.Value,
          FreeOfChargeProduct =freeOfChargeProduct==null ?null: new ProductRef { ProductId=freeOfChargeProduct.Value},
          EffectiveDate=effectiveDate,
          EndDate = endDate,
          DiscountRate=DiscountRate,
          _Status = EntityStatus.New, 
       });
      return foc;
  }
Example #8
0
 public ProductPricing Map(ProductPricingDTO dto)
 {
     if (dto == null) return null;
     var productPricing = Mapper.Map<ProductPricingDTO, ProductPricing>(dto);
     var productRef = new ProductRef { ProductId = dto.ProductMasterId };
     productPricing.ProductRef = productRef;
     productPricing.Tier = _pricingTierRepository.GetById(dto.ProductPricingTierMasterId);
     productPricing.ProductPricingItems = dto.ProductPricingItems.Select(n => Map(n)).ToList();
     return productPricing;
 }
Example #9
0
 protected Guid AddCertainValueCertainProductDiscount(ProductRef product, int Quantity, decimal rate, DateTime effDate, DateTime endDate)
 {
     CertainValueCertainProductDiscount svd = _certainValueCertainProductDiscountFactory.CreateCertainValueCertainProductDiscount(product, Quantity, rate, effDate, endDate);
     svd._SetStatus(EntityStatus.Active);
     return _certainValueCertainProductDiscountRepository.Save(svd);
 }
Example #10
0
 protected Guid AddFreeOfChargeDiscountDiscount(ProductRef product, DateTime startDate, DateTime endDate)
 {
     var svd = new FreeOfChargeDiscount(Guid.NewGuid())
                                    {
                                        isChecked=true,
                                        StartDate = startDate,
                                        EndDate = endDate,
                                        ProductRef=product,
                                    };
     svd._SetStatus(EntityStatus.Active);
     return _freeOfChargeDiscountRepository.Save(svd);
 }
Example #11
0
 protected Guid AddPromotionDiscount(ProductRef parentProduct, Guid freeProduct, int ParentQuantity, int FreeQuantity, decimal rate, DateTime effDate, DateTime endDate)
 {
     PromotionDiscount svd = _promotionDiscountFactory.CreateFreeOfChargeDiscount(parentProduct, freeProduct, ParentQuantity, FreeQuantity, effDate, rate, endDate);
     svd._SetStatus(EntityStatus.Active);
     return _promotionDiscountRepository.Save(svd);
 }
Example #12
0
 protected Guid AddProductGroupDiscount(DiscountGroup group, ProductRef productRef, decimal rate, DateTime effDate, DateTime endDate)
 {
     ProductGroupDiscount svd = _productDiscountGroupFactory.CreateProductGroupDiscount(group, productRef, rate, effDate, endDate,false,0);
     svd._SetStatus(EntityStatus.Active);
     return _productDiscountGroupRepository.Save(svd);
 }
 private async Task <BlobClient> OpenBlobClient(ProductRef product) =>
 (await this.GetBlobContainer()).GetBlobClient(product.Value);
 public async Task WriteAsync(Image image, ProductRef product)
 {
     using Stream stream = this.Load(image);
     await(await this.OpenBlobClient(product)).UploadAsync(stream, true);
 }