Example #1
0
        public Task InsertPrice(string sku, InsertPrice price)
        {
            if (price == null || string.IsNullOrEmpty(sku))
            {
                throw new Exception("Cannot add price, because price is null or item sku not defined");
            }

            return(_priceRepository.InsertPrice(sku, price));
        }
Example #2
0
        public async Task <IActionResult> Update(string sku, int priceId, [FromBody] InsertPrice insertPrice)
        {
            if (insertPrice == null || decimal.Parse(insertPrice.Price) < 1 || priceId < 1 || string.IsNullOrEmpty(sku))
            {
                throw new Exception("Invalid information entered");
            }

            await _priceService.UpdateSelectedPrice(sku, priceId, insertPrice);

            await _context.SaveChangesAsync();

            return(Ok());
        }
Example #3
0
        public async Task UpdateSelectedPrice(string sku, int priceId, InsertPrice updatedItem)
        {
            var entity = await _context.Prices.FindAsync(priceId);

            if (entity == null)
            {
                throw new Exception("Price you are trying to update does not exist");
            }
            if (sku.ToUpper() != entity.ItemSku.ToUpper())
            {
                throw new Exception("Sku you are trying to update does not exist");
            }

            entity.Active = updatedItem.Active;
            entity.Price  = Math.Round(decimal.Parse(updatedItem.Price), 2);
        }
Example #4
0
        public async Task InsertPrice(string sku, InsertPrice price)
        {
            if (price == null)
            {
                throw new Exception("Cannot add price, because price is null");
            }

            var entity = new PriceEntity
            {
                Active  = price.Active,
                ItemSku = sku.ToUpper(),
                Price   = decimal.Parse(price.Price)
            };

            await _context.Prices.AddAsync(entity);
        }
Example #5
0
        public async Task <InsertPrice> GetSelectedPrice(string sku, int priceId)
        {
            if (string.IsNullOrEmpty(sku) || priceId < 1)
            {
                throw new Exception("Invalid data");
            }

            var price = await _priceRepository.GetSelectedPrice(sku, priceId);

            var model = new InsertPrice()
            {
                Active = price.Active,
                Price  = price.Price.ToString()
            };

            return(model);
        }
Example #6
0
        //ADD TO PRODUCT LIST
        private void AddToList_Click(object sender, RoutedEventArgs e)
        {
            //if (InsertTag.Text == "Yes")
            //{
            //    var Value = Int32.Parse(InsertPrice.Text);
            //    var AddedRegulation = Value + ((Value / 100m) * 20m);
            //    InsertPrice.Text = AddedRegulation.ToString();
            //}
            AList.Add(new Product()
            {
                Name = InsertName.Text, Price = InsertPrice.Text,                       /*Tag = InsertTag.Text*/
            });

            ProductsAndPrices.ItemsSource = AList;
            ProductsAndPrices.Items.Refresh();
            InsertName.Clear();
            InsertPrice.Clear();
        }
Example #7
0
 public Task UpdateSelectedPrice(string sku, int priceId, InsertPrice updatedItem)
 {
     return(_priceRepository.UpdateSelectedPrice(sku, priceId, updatedItem));
 }