Exemplo n.º 1
0
        public IActionResult GetBuyer(int id, [FromServices] IBuyerService service)
        {
            Dto foundBuyer        = Wrapper.GetMapper.Map <Dto>(service.GetBuyer(id));
            var listOfAllBuyers   = service.GetBuyers();
            var fixedListOfBuyers = listOfAllBuyers
                                    .Except(foundBuyer.ElementAsList());

            foundBuyer.Buyers          = fixedListOfBuyers.ToList();
            foundBuyer.buyerInDropdown = $"{foundBuyer.Name} {foundBuyer.Surname}";
            return(View("Index", foundBuyer));
        }
Exemplo n.º 2
0
 private void FormClient_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             BuyerViewModel view = service.GetBuyer(id.Value);
             if (view != null)
             {
                 textBoxFIO.Text = view.BuyerFIO;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 3
0
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Buyer buyer = _BuyerService.GetBuyer(id);

            if (buyer == null)
            {
                return(HttpNotFound());
            }

            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }
Exemplo n.º 4
0
        static void OrderAndSellArticle(ISupplierService supplierService, IBuyerService buyerService, IShopService shopService, IArticleService articleService)
        {
            int    id = 1;
            string ean;
            // Get article for order and sell article example (EAN is needed, that's why this call is made)
            Article article = articleService.GetArticle(id);

            double maxExpectedPrice = 8.00;

            ean = article.EAN;

            Console.WriteLine($"Ordering article with EAN={article.EAN} ...");
            article = supplierService.OrderArticle(article.EAN, maxExpectedPrice);

            if (article == null)
            {
                Console.WriteLine($"Article with EAN={ean} for price less or equal then {maxExpectedPrice} not found");
            }
            else
            {
                Console.WriteLine($"Article with EAN={article.EAN} for price less or equal then {maxExpectedPrice} found");
                Buyer buyer = buyerService.GetBuyer(1);

                try
                {
                    Console.WriteLine($"Selling article with id={article.Id} to buyer {buyer.Name} ...");
                    shopService.SellArticle(article, buyer);
                    Console.WriteLine($"Sold article with i={article.Id} to buyer {buyer.Name}");
                }
                catch
                {
                    Console.WriteLine($"Cannot sell article to buyer, returning it to supplier ... ");
                    supplierService.ReturnArticleToSupplier(article);
                    Console.WriteLine($"Article with id={article.Id} returned to supplier");
                }
            }
        }