Exemple #1
0
        public void AddToy()
        {
            string ToyName, Description, CategoryName, PlantName;
            int    Price;

            using (var toyapp = new ToyApplicationDbContext())
            {
                Console.WriteLine("Enter Toy Name");
                ToyName = Console.ReadLine();
                Console.WriteLine("Enter Toy Description");
                Description = Console.ReadLine();
                Console.WriteLine("Enter Price");
                Price = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter Category Name");
                CategoryName = Console.ReadLine();

                int CategoryId = toyapp.ToyCategory.SingleOrDefault <ToyCategory>(t => t.ToyCategoryName == CategoryName).ToyCategoryId;
                Console.WriteLine("Enter Plant Name");
                PlantName = Console.ReadLine();
                int PlantId = toyapp.Plants.SingleOrDefault <Plants>(t => t.PlantName == PlantName).PlantId;

                var toy = new Toys
                {
                    ToyName     = ToyName,
                    Description = Description,
                    Price       = Price,
                    CategoryId  = CategoryId,
                    PlantId     = PlantId
                };
                toyapp.Toys.Add(toy);
                toyapp.SaveChanges();
                Console.WriteLine(" Toy  Successfully Added");
            }
        }
Exemple #2
0
 public static void AddToysDetails()
 {
     using (var db = new MasterContext())
     {
         var toy = new Toys();
         {
             Console.WriteLine("Enter ToyName!!");
             toy.ToyName = Console.ReadLine();
             Console.WriteLine("Enter ToyDescription!!");
             toy.ToyDescription = Console.ReadLine();
             Console.WriteLine("Enter ToyPrice!!");
             toy.ToyPrice = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine("Enter ToyBrand!!");
             toy.ToyBrand = Console.ReadLine();
             Console.WriteLine("Enter ToysCategoryId!!");
             toy.ToysCategoryId = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine("Enter PlantsId!!");
             toy.PlantId = Convert.ToInt32(Console.ReadLine());
             var check = db.Toys.Where(t => t.ToyName == toy.ToyName);
             if (check != null)
             {
                 Console.WriteLine("Toy Name is Existing");
             }
             else
             {
                 db.Toys.Add(toy);
                 db.SaveChanges();
                 Console.WriteLine("Toys Information is added Successfully!!");
             }
         }
     }
 }
Exemple #3
0
        static void addToy()
        {
            using (var context = new Context())
            {
                Admin ad = new Admin();
                Console.WriteLine("Enter UserName");
                ad.UserName = Console.ReadLine();
                Console.WriteLine("Enter Password");
                ad.Password = Console.ReadLine();
                var check = context.Admins.SingleOrDefault(t => t.UserName == ad.UserName && t.Password == ad.Password);
                if (check != null)
                {
                    try
                    {
                        Toys dp = new Toys();
                        Console.WriteLine("Enter Toy Name");
                        dp.ToyName = Console.ReadLine();
                        Console.WriteLine("Enter Toy Price");
                        dp.ToyPrice = Console.ReadLine();

                        context.Toys.Add(dp);
                        context.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
                else
                {
                    Console.WriteLine("Incorrect UserName or Password");
                }
            }
        }
Exemple #4
0
        public async Task <IActionResult> PutToys(int id, Toys toys)
        {
            if (id != toys.ToyId)
            {
                return(BadRequest());
            }

            _context.Entry(toys).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ToysExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #5
0
        public async Task <ActionResult <Toys> > PostToys(Toys toys)
        {
            _context.Toys.Add(toys);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetToys", new { id = toys.ToyId }, toys));
        }
Exemple #6
0
        public void Purchase()
        {
            VendingMachine vm = new VendingMachine();

            int[] sumCredit = vm.EndTransaction();

            vm.InsertMoney(1000);

            Beverages beer = new Beverages(0.055, "Bryggmästarens", 99, true, "Bryggmästarens Premium gold är ett exklusivt öl framtaget med förstklassiga råvaror", "Drink it cold", 25);

            vm.Purchase(beer);
            vm.Purchase(beer);

            Food hotdish = new Food("Thai", "Hot Curry", 850, true, "Traditional thai dish", "Eat while warm. Drink milk if too hot", 125);

            vm.Purchase(hotdish);

            Food dessert = new Food("Italian", "tiramisu", 200, true, "Classic italian dessert", "Enjoy this delight with a cappuchino", 30);

            vm.Purchase(dessert);

            Beverages coffee = new Beverages(0, "Espresso", 0, true, "Black italian coffee with crema on top", "Enjoy any time during the day.", 10);

            vm.Purchase(coffee);

            Toys rubicscube = new Toys(5, "Rubic's cube", 0, false, "Rubik's Cube is a 3D combination puzzle invented in 1974 by Hungarian sculptor and professor of architecture Ernő Rubik", "Twist and turn in enternity", 40);

            vm.Purchase(rubicscube);

            Assert.NotEqual(vm.Purchase(beer), vm.Purchase(dessert));
        }
Exemple #7
0
        private async void RemoveExecute()
        {
            Int64 startTicks = Log.VIEWMODEL("(ToyDetailViewModel) Enter", Common.LOG_CATEGORY);

            var isReferenced =
                await _ToyDataService.IsReferencedByCatAsync(SelectedToy.Id);

            if (isReferenced)
            {
                var message = $"The Cat ({SelectedToy.Name})" +
                              " can't be removed;  It is referenced by at least one Cat";

                DialogService.Show("NotificationDialog", new DialogParameters($"message={message}"), r =>
                {
                });

                return;
            }

            SelectedToy.PropertyChanged -= Wrapper_PropertyChanged;
            _ToyDataService.Remove(SelectedToy.Model);
            Toys.Remove(SelectedToy);
            SelectedToy = null;
            HasChanges  = _ToyDataService.HasChanges();

            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();

            Log.VIEWMODEL("(ToyDetailViewModel) Exit", Common.LOG_CATEGORY, startTicks);
        }
        public void AddProductsIntoList()
        {
            List <Product> purchases = new List <Product>();

            Beverages beer = new Beverages(0.055, "Bryggmästarens", 99, true, "Bryggmästarens Premium gold är ett exklusivt öl framtaget med förstklassiga råvaror", "Drink it cold", 25);

            purchases.Add(beer);

            //test idential product
            purchases.Add(beer);

            Food hotdish = new Food("Thai", "Tom Yum Goong", 275, true, "This iconic bowl of steaming goodness is bold, aromatic and comes with a fairly strong spicy kick", "Eat it with spoon and a fork", 125);;

            purchases.Add(hotdish);

            Food dessert = new Food("Italian", "tiramisu", 200, true, "Classic italian dessert", "Enjoy this delight with a cappuchino", 30);

            purchases.Add(dessert);

            Beverages coffee = new Beverages(0, "Espresso", 0, true, "Black italian coffee with crema on top", "Enjoy any time during the day.", 10);

            purchases.Add(coffee);

            Toys rubicscube = new Toys(5, "Rubic's cube", 0, false, "Rubik's Cube is a 3D combination puzzle invented in 1974 by Hungarian sculptor and professor of architecture Ernő Rubik", "Twist and turn in enternity", 40);

            purchases.Add(rubicscube);

            Assert.NotNull(beer);
            Assert.Equal(6, purchases.Count);
        }
Exemple #9
0
        static void Main(string[] args)
        {
            Toys toy = new Toys("HelloKitty", "USA");

            toy.DisplayInfo();
            toy.DisplayCountry();
        }
Exemple #10
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Image,UnderAge,Price,QuantityInStock")] Toys toys)
        {
            if (id != toys.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(toys);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ToysExists(toys.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(toys));
        }
Exemple #11
0
        static void removeToy()
        {
            using (var context = new Context())
            {
                Admin ad = new Admin();
                Console.WriteLine("Enter UserName");
                ad.UserName = Console.ReadLine();
                Console.WriteLine("Enter Password");
                ad.Password = Console.ReadLine();
                var check = context.Admins.SingleOrDefault(t => t.UserName == ad.UserName && t.Password == ad.Password);
                if (check != null)
                {
                    try
                    {
                        Toys hp = new Toys();
                        Console.WriteLine("Enter Toys Id");
                        hp.ToyId = Convert.ToInt32(Console.ReadLine());

                        context.Toys.Remove(hp);
                        context.SaveChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
                else
                {
                    Console.WriteLine("Incorrect UserName or Password");
                }
            }
        }
Exemple #12
0
        private void addButton_Click(object sender, EventArgs e)
        {
            Toys toy = (Toys)toyTypeCombo.SelectedItem;

            switch (toy)
            {
            case Toys.BOAT:
                toyInstanceCombo.Items.Add(new Boat());
                break;

            case Toys.CAR:
                toyInstanceCombo.Items.Add(new Car());
                break;

            case Toys.PLANE:
                toyInstanceCombo.Items.Add(new Plane());
                break;

            case Toys.STONE:
                toyInstanceCombo.Items.Add(new Stone());
                break;

            case Toys.AMFIBIA:
                toyInstanceCombo.Items.Add(new Amfibia());
                break;

            default:

                break;
            }
        }
Exemple #13
0
        // GET: Toy
        public ActionResult Index()
        {
            var  toys  = db.GetAllToys();
            Toys model = new Toys();

            model.EntityList.AddRange(toys.ToList());
            return(View(model));
        }
Exemple #14
0
 // GET: Toys/Details/5
 public ActionResult Details(int id)
 {
     using (HPContext context = new HPContext())
     {
         Toys t = context.Toys.Find(id);
         return(View(t));
     }
 }
        public StaffsController()
        {
            _connection = new SqlConnection("server=DESKTOP-D2JHR9D\\SQLEXPRESS;database=StaffManagement;user id=sa; password=tola;MultipleActiveResultSets=True");
            //SELECT[Staff_Id],[First_Name],[Last_Name],[Bod],[Education],[Religion]

            //_toys = new Toys("Green",5);
            _toys = new Toys();
        }
Exemple #16
0
        /// <summary>
        /// Finishes the cabinet
        /// </summary>
        public void Finish()
        {
            Log.Write("Finishing cabinet");

            Toys.Finish();
            OutputControllers.Finish();
            Log.Write("Cabinet finished");
        }
        public ActionResult Index()
        {
            ProjectMongoDB db    = new ProjectMongoDB();
            var            toys  = db.GetAllToy();
            Toys           model = new Toys();

            model.EntityList = toys.ToList();
            return(View(model));
        }
Exemple #18
0
        /// <summary>
        /// Initializes the cabinet.
        /// <param name="CabinetOwner">The ICabinetOwner object for the cabinet instance.</param>
        /// </summary>
        public void Init(ICabinetOwner CabinetOwner)
        {
            Log.Write("Initializing cabinet");
            this.Owner = CabinetOwner;
            OutputControllers.Init(this);
            Toys.Init(this);

            Log.Write("Cabinet initialized");
        }
Exemple #19
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Toys.Destroy(id))
     {
         return(RedirectToAction("Index"));
     }
     ViewBag.Error = string.Join("\n", ModelState.Values.SelectMany(x => x.Errors));
     return(View());
 }
Exemple #20
0
        /// <summary>
        /// Initializes the cabinet.
        /// </summary>
        /// <param name="Pinball">The Pinball object using the Cabinet instance.</param>
        public void Init(Pinball Pinball)
        {
            Log.Write("Initializing cabinet");
            this.Pinball = Pinball;
            OutputControllers.Init(this);
            Toys.Init(this);

            Log.Write("Cabinet initialized");
        }
Exemple #21
0
        // GET: Toys/Delete/5
        public ActionResult Delete(int id)
        {
            Toys result = null;

            using (HPContext context = new HPContext())
            {
                result = context.Toys.Find(id);
                return(View(result));
            }
        }
Exemple #22
0
        public ActionResult Index()
        {
            xmasDB db    = new xmasDB();
            var    toys  = db.GetAllToys().ToList();
            Toys   model = new Toys
            {
                EntityList = toys
            };

            return(View(model));
        }
Exemple #23
0
        public async Task <IActionResult> Create([Bind("Id,Image,UnderAge,Price,QuantityInStock")] Toys toys)
        {
            if (ModelState.IsValid)
            {
                _context.Add(toys);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(toys));
        }
 public async void LoadProduct(int productId)
 {
     try
     {
         SelectedToys = await DataStore.GetProductAsync(productId) as Toys;
     }
     catch (Exception)
     {
         Debug.WriteLine("Failed to Load Item");
     }
 }
Exemple #25
0
        static void getToy()
        {
            using (var context = new Context())
            {
                Toys hp = new Toys();

                foreach (var item in context.Toys.ToList())
                {
                    Console.WriteLine($"ID {item.ToyId} - Name {item.ToyName}- ToyPrice{item.ToyPrice}");
                }
            }
        }
Exemple #26
0
 void Start()                                                                                                // --> Init
 {
     obj_Game_Manager = GameObject.Find("Manager_Game");                                                     // Find the gameObject Manager_Game
     if (obj_Game_Manager != null)
     {
         gameManager = obj_Game_Manager.GetComponent <Manager_Game>();                               // Access Manager_Game from obj_Game_Manager
     }
     sound_ = GetComponent <AudioSource>();                                                          // Access AudioSource Component
     if (Toy)
     {
         toy = Toy.GetComponent <Toys>();                                                                            // access Toys component if needed
     }
 }
Exemple #27
0
 public IActionResult AddItem(Toys Toy)
 {
     if (ModelState.IsValid)
     {
         db_context.Toys.Add(Toy);
         db_context.SaveChanges();
         return(RedirectToAction("Toys"));
     }
     else
     {
         return(View("CreateItem"));
     }
 }
Exemple #28
0
        public ActionResult Delete(int?id)
        {
            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Toys toys = Toys.FindOne(id.Value);

            if (toys == null)
            {
                return(HttpNotFound());
            }
            return(View(toys));
        }
        public ToyDistributionSolution CreateSolution()
        {
            var dictionary = new Dictionary <string, string>();

            List <Toy>   problemToys     = Toys.ToList();
            List <Child> problemChildren = Children.ToList();

            foreach (Child c in problemChildren)
            {
                // Remove all toy wishes not in Santas bag
                c.WishList.Toys.RemoveAll(x => !problemToys.Contains(x));
            }

            List <InterestingToy> interestingToys = InterestingToys(problemChildren.ToArray())
                                                    .Where(x => problemToys.Contains(x.Toy))
                                                    .Reverse()
                                                    .ToList();

            while (problemChildren.Any())
            {
                Child[] children = problemChildren.Where(x => x.WishList.Toys.Count == 1).ToArray();

                if (!children.Any())
                {
                    return(null);
                }

                foreach (Child child in children)
                {
                    Toy toy = child.WishList.Toys.First();

                    dictionary.Add(child.Name, toy.Name);
                    interestingToys.Remove(interestingToys.Find(x => x.Toy.Equals(toy)));
                    foreach (Child problemChild in problemChildren)
                    {
                        problemChild.WishList.Toys.Remove(toy);
                    }
                }

                foreach (Child child in children)
                {
                    problemChildren.Remove(child);
                }
            }

            return(new ToyDistributionSolution {
                List = dictionary
            });
        }
Exemple #30
0
 public ActionResult Index()
 {
     if (Session["IsAdmin"] != null)
     {
         Classes.MongoDB db    = new Classes.MongoDB();
         var             toys  = db.GetAllToys();
         Toys            model = new Toys();
         model.ToysList = toys.ToList();
         return(View(model));
     }
     else
     {
         return(RedirectToAction("../Users/Login"));
     }
 }