Exemplo n.º 1
0
        public IActionResult DeleteStorage(ViewChoiceStorage info)
        {
            Storage storage = storegeRepository.Storages.Where(p => p.Id == info.SelectedStorage).FirstOrDefault();

            if (storage != null)
            {
                storegeRepository.DeleteStorage(storage);
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public IActionResult SumProduct(ViewChoiceStorage info)
        {
            var            prod           = storegeRepository.StorageWithProd(info.SelectedStorage);
            List <Product> products       = prod.ProductStorages.Select(x => x.Product).ToList();
            double         SumBasicCurren = products.Sum(p => p.BasicCurrPrice * p.Count);
            double         SumPriceProd   = SumBasicCurren / currencyRepository.Currencies.FirstOrDefault(p => p.Id == info.SelectedCurrency)
                                            .ExchangeRate;

            return(View(new ViewSumPrice {
                Curr = currencyRepository.Currencies.
                       FirstOrDefault(p => p.Id == info.SelectedCurrency).ShortName, StorName = storegeRepository.Storages
                                                                                                .FirstOrDefault(p => p.Id == info.SelectedStorage).Name, Sum = SumPriceProd
            }));
        }
Exemplo n.º 3
0
        public IActionResult EditStorage(ViewChoiceStorage info)
        {
            Storage storage = storegeRepository.Storages.Where(p => p.Id == info.SelectedStorage).FirstOrDefault();

            if (info.NewName != null && storage != null)
            {
                storage.Name = info.NewName;
                storegeRepository.EditStorage(storage);
            }
            if (info.NewAdress != null && storage != null)
            {
                storage.Address = info.NewAdress;
                storegeRepository.EditStorage(storage);
            }

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 4
0
        public IActionResult DisplayStorage(ViewChoiceStorage info)
        {
            var                x            = storegeRepository.StorageWithProd(info.SelectedStorage);
            List <Product>     prod         = x.ProductStorages.Select(x => x.Product).ToList();
            List <ViewProduct> viewProducts = prod.Select(x => new ViewProduct
            {
                Name           = x.Name,
                Id             = x.Id,
                Barcode        = x.Barcode,
                BasicCurrPrice = x.BasicCurrPrice,
                Count          = x.Count,
                Price          = x.Price,
                CategoryName   = x.Category.Name,
                CurrencyName   = x.Currency.ShortName
            }).ToList();

            return(View("Display", viewProducts));
        }