public IActionResult Orders(HttpResponse response, BuyerBindingModel bbm)
        {
            var buyer = this.context.Buyers.FirstOrDefault(b => b.Name == bbm.Name && b.Address == bbm.Address);

            buyer.DeliveryStatus = bbm.DeliveryStatus;
            this.context.Buyers.AddOrUpdate(buyer);
            this.context.SaveChanges();
            Redirect(response, "/admin/orders");
            return(null);
        }
        public void AddBuyer(BuyerBindingModel model)
        {
            int maxId = 0;

            for (int i = 0; i < source.Buyers.Count; ++i)
            {
                if (source.Buyers[i].Id > maxId)
                {
                    maxId = source.Buyers[i].Id;
                }
                if (source.Buyers[i].BuyerFIO == model.BuyerFIO)
                {
                    throw new Exception("Уже есть покупатель с таким ФИО");
                }
            }
            source.Buyers.Add(new Buyer
            {
                Id       = maxId + 1,
                BuyerFIO = model.BuyerFIO
            });
        }
        public void UpdBuyer(BuyerBindingModel model)
        {
            int index = -1;

            for (int i = 0; i < source.Buyers.Count; ++i)
            {
                if (source.Buyers[i].Id == model.Id)
                {
                    index = i;
                }
                if (source.Buyers[i].BuyerFIO == model.BuyerFIO &&
                    source.Buyers[i].Id != model.Id)
                {
                    throw new Exception("Уже есть покупатель с таким ФИО");
                }
            }
            if (index == -1)
            {
                throw new Exception("Покупатель не найден");
            }
            source.Buyers[index].BuyerFIO = model.BuyerFIO;
        }