コード例 #1
0
ファイル: PriceService.cs プロジェクト: M4ntha5/kika-group
        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));
        }
コード例 #2
0
ファイル: PriceController.cs プロジェクト: M4ntha5/kika-group
        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());
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #5
0
ファイル: PriceService.cs プロジェクト: M4ntha5/kika-group
        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);
        }
コード例 #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();
        }
コード例 #7
0
ファイル: PriceService.cs プロジェクト: M4ntha5/kika-group
 public Task UpdateSelectedPrice(string sku, int priceId, InsertPrice updatedItem)
 {
     return(_priceRepository.UpdateSelectedPrice(sku, priceId, updatedItem));
 }