Пример #1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            MaterialSeller materialSeller = db.MaterialSellers.Find(id);

            db.MaterialSellers.Remove(materialSeller);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Id,Name")] MaterialSeller materialSeller)
 {
     if (ModelState.IsValid)
     {
         db.Entry(materialSeller).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(materialSeller));
 }
Пример #3
0
        public ActionResult Create([Bind(Include = "Id,Name")] MaterialSeller materialSeller)
        {
            if (ModelState.IsValid)
            {
                materialSeller.Id = Guid.NewGuid();
                db.MaterialSellers.Add(materialSeller);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(materialSeller));
        }
Пример #4
0
        // GET: Commerce/MaterialSellers/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MaterialSeller materialSeller = db.MaterialSellers.Find(id);

            if (materialSeller == null)
            {
                return(HttpNotFound());
            }
            return(View(materialSeller));
        }
Пример #5
0
        private static void ClientMenu(FurnitureSeller furnitureSeller, VendingMachine1 vendingMachine)
        {
            int option = -1;

            while (option != 0)
            {
                Console.WriteLine("0. Exit");
                Console.WriteLine("1. Create");
                Console.WriteLine("2. Decorate");
                Console.WriteLine("3. Check a product");
                Console.WriteLine("4. Buy");
                Console.WriteLine("5. Insert Money");
                Console.WriteLine("6. Redraw Money");
                Console.WriteLine("7. Inspect stock");
                Console.WriteLine("8. See your money ammount");

                try
                {
                    option = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                switch (option)
                {
                case 1:


                    EMaterialMixType materialMixType = GetMaterialType();
                    MaterialSeller   createSeller    = new MaterialSeller(new MaterialMixBuilder(), materialMixType);
                    MaterialMix      createdMaterial = createSeller.GetResult();
                    string           name;
                    EFurnitureType   furnitureType;
                    do
                    {
                        Console.WriteLine("Chair");
                        Console.WriteLine("Lift chair");
                        Console.WriteLine("Bar chair");
                        Console.WriteLine("Bench");
                        Console.WriteLine("Couch");
                        Console.WriteLine("Chesterfield");
                        Console.WriteLine("Bed");
                        Console.WriteLine("Day bed");
                        Console.WriteLine("Sofa bed");
                        Console.WriteLine("Biliard table");
                        Console.WriteLine("Television set");
                        Console.WriteLine("Coffe table");
                        Console.WriteLine("Dining table");
                        Console.WriteLine();
                        Console.WriteLine("Introduce the name of the product:");
                        name          = Console.ReadLine();
                        furnitureType = GetFurnitureType(name);
                    } while (furnitureType == EFurnitureType.ENone);


                    furnitureSeller.OrderFurniture(createdMaterial.Price, name, EFurnitureComplexity.Easy, new MaterialMix(), furnitureType);
                    break;

                case 2:
                    materialMixType = GetMaterialType();
                    createSeller    = new MaterialSeller(new MaterialMixBuilder(), materialMixType);
                    createdMaterial = createSeller.GetResult();
                    IMaterialAccesory materialAccesory = createdMaterial;

                    do
                    {
                        Console.WriteLine("Chair");
                        Console.WriteLine("Lift chair");
                        Console.WriteLine("Bar chair");
                        Console.WriteLine("Bench");
                        Console.WriteLine("Couch");
                        Console.WriteLine("Chesterfield");
                        Console.WriteLine("Bed");
                        Console.WriteLine("Day bed");
                        Console.WriteLine("Sofa bed");
                        Console.WriteLine("Biliard table");
                        Console.WriteLine("Television set");
                        Console.WriteLine("Coffe table");
                        Console.WriteLine("Dining table");
                        Console.WriteLine();
                        Console.WriteLine("Introduce the name of the product:");
                        name          = Console.ReadLine();
                        furnitureType = GetFurnitureType(name);
                    } while (furnitureType == EFurnitureType.ENone);

                    Console.WriteLine("1. Extendable");
                    Console.WriteLine("2. Handle");
                    Console.WriteLine("3. Height adjusted");
                    Console.WriteLine("4. Upholstered");

                    var op = 0;
                    do
                    {
                        try
                        {
                            Console.WriteLine("Choose a number.");
                            op = Convert.ToInt32(Console.ReadLine());
                            if (op < 1 || op > 4)
                            {
                                op = 0;
                            }
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Choose a number between 1 and 4!");
                        }
                    } while (op == 0);

                    switch (op)
                    {
                    case 1:
                        materialAccesory = new ExtendableDecorator(materialAccesory);
                        break;

                    case 2:
                        materialAccesory = new HandleDecorator(materialAccesory);
                        break;

                    case 3:
                        materialAccesory = new HeightAdjustedDecorator(materialAccesory);
                        break;

                    case 4:
                        materialAccesory = new UpholsteredDecorator(materialAccesory);
                        break;
                    }

                    //Console.WriteLine("What color do you want?");
                    //string color = Console.ReadLine();
                    materialAccesory.Assemble();



                    furnitureSeller.OrderFurniture(materialAccesory.Price, name, EFurnitureComplexity.Hard, new MaterialMix(), furnitureType);
                    break;

                case 3:
                    Seller       my_seller = new Seller(furnitureSeller);
                    RequestPrice request   = new RequestPrice(my_seller);
                    Console.WriteLine("Introduce the name of the product you want to check:");
                    string product = Console.ReadLine();
                    double price   = request.GetProductPrice(product);
                    if (price == -1)
                    {
                        Console.Write("Can't find this product.");
                    }
                    else
                    {
                        Console.WriteLine("We found your product.It's price is: " + price);
                    }
                    break;

                case 4:
                    Console.WriteLine("Choose your product Id");
                    int value = Convert.ToInt32(Console.ReadLine());
                    vendingMachine.UpdateState(EClientOption.BuyProduct, value, value, EMoneyType.Card);
                    break;

                case 5:
                    Console.WriteLine("How much do you want to add to your account?");
                    value = Convert.ToInt32(Console.ReadLine());
                    vendingMachine.UpdateState(EClientOption.InsertMoney, value, int.MaxValue, EMoneyType.Card);
                    break;

                case 6:
                    Console.WriteLine("How much do you want to redraw?");
                    value = Convert.ToInt32(Console.ReadLine());
                    vendingMachine.UpdateState(EClientOption.RetractMoney, value, int.MaxValue, EMoneyType.Card);
                    break;

                case 7:
                    vendingMachine.UpdateState(EClientOption.InspectStock, double.NaN, int.MaxValue, EMoneyType.Card);
                    break;

                case 8:
                    vendingMachine.UpdateState(EClientOption.SeeMoneyAmmount, int.MaxValue, int.MaxValue, EMoneyType.Card);
                    break;

                default:
                    break;
                }
            }
        }