Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,Cod,Nume,Locatie")] Magazin magazin)
        {
            if (id != magazin.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(magazin);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MagazinExists(magazin.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(magazin));
        }
Ejemplo n.º 2
0
        public Magazin Delete(Magazin Magazin)
        {
            var result = _context.Remove(Magazin);

            _context.SaveChanges();
            return(result.Entity);
        }
Ejemplo n.º 3
0
        // GET: Magazine
        public async Task <IActionResult> Index(int?id, int?costumID)
        {
            var viewModel = new MagazinIndexData();

            viewModel.Magazine = await _context.Magazine
                                 .Include(i => i.MagazinCostume)
                                 .ThenInclude(i => i.Costum)
                                 .ThenInclude(i => i.Orders)
                                 .ThenInclude(i => i.Customer)
                                 .AsNoTracking()
                                 .OrderBy(i => i.MagazinName)
                                 .ToListAsync();

            if (id != null)
            {
                ViewData["MagazinID"] = id.Value;
                Magazin magazin = viewModel.Magazine.Where(
                    i => i.ID == id.Value).Single();
                viewModel.Costume = magazin.MagazinCostume.Select(s => s.Costum);
            }
            if (costumID != null)
            {
                ViewData["CostumID"] = costumID.Value;
                viewModel.Orders     = viewModel.Costume.Where(
                    x => x.ID == costumID).Single().Orders;
            }
            return(View(viewModel));
        }
Ejemplo n.º 4
0
        public void Test_GetBullet()
        {
            var model  = new MockRoyalGameModel();
            var player = new MockPlayer()
            {
                Model = model
            };
            var weapon = new Weapon(model, TypesGameObject.Weapon, TypesBehaveObjects.Active, TypesWeapon.Gun);

            (weapon as Weapon).Owner = player;
            Magazin magazin = new Magazin(weapon, TypesWeapon.Gun, 50, 300, 8);

            magazin.Setup();

            //делаем 8 выстрелов
            for (int i = 0; i < 8; i++)
            {
                Assert.IsNotNull(magazin.GetBullet());
                Assert.IsNull(magazin.GetBullet());
                magazin.Parent.Update(new TimeQuantPassed(51));
            }
            //перезаряжаем
            Assert.IsNull(magazin.GetBullet());
            magazin.Parent.Update(new TimeQuantPassed(301));
            Assert.IsNotNull(magazin.GetBullet());
        }
        //
        // GET: /ShoppingListPerStore/

        public ViewResult Index()
        {
            tipProdusList = Session["ShoppingList"] as List <TipProdus>;

            if (tipProdusList == null)
            {
                throw new Exception("Nu este Lista de cumparaturi in Sesiune!");
            }
            //  tipProdusList = db.TipProduse.ToList();
            produseList = db.Produse.ToList();
            //s tipProdusList = db.TipProduse.Where(p => p.Id == 1).ToList();
            magazine = db.Magazine.ToList();

            foreach (var tipProdus in tipProdusList)
            {
                var produse = produseList.Where(p => p.IdTipProdus == tipProdus.Id);
                var listaMagazinePerProdus = produse.Select(p => p.Magazin).ToList();
                magazine = magazine.Intersect(listaMagazinePerProdus).ToList();
            }

            var     pretMinim          = decimal.MaxValue;
            Magazin magazinCuPretMinim = null;

            foreach (Magazin magazin in magazine)
            {
                shop.PretTotal = (from x in produseList
                                  where x.IdMagazin == magazin.Id
                                  select x.Pret).Sum();
                if (pretMinim > shop.PretTotal)
                {
                    pretMinim          = shop.PretTotal;
                    magazinCuPretMinim = magazin;
                }
                shop.MagazinId = magazin.Id;
                shop.Produse   = produseList;
                shop.TipProdus = tipProdusList;
                shoppingList.Add(shop);
                RefreshShoppingList();
            }


            if (shoppingList.Count() == 0)
            {
                return(View("NoData"));
            }

            string email   = Membership.GetUser().Email;
            string subject = "Comanda realizata la magazinul ales";
            string content = string.Format("Buna ziua! \r\n Ne bucuram ca puteti face o alegere cu ajutorul aplicatiei noastre de usurat viata! \r\n Ati ales produsele: \r\n");

            foreach (var product in produseList)
            {
                content += string.Format("{0} {1} {2} \r\n", product.TipProdus.Denumire, product.TipProdus.UnitateMasura, product.Pret);
            }

            content += string.Format(" de la magazinul {0}", magazinCuPretMinim.Nume);
            HomeController.GmailTeste(email, subject, content);

            return(View("Index", shoppingList));
        }
Ejemplo n.º 6
0
        public Magazin Create(Magazin magazin)
        {
            var result = _context.Add <Magazin>(magazin);

            _context.SaveChanges();
            return(result.Entity);
        }
Ejemplo n.º 7
0
            public Task3()
            {
                Magazin magaz = new Magazin("Астыкжан");

                magaz.AddAsis(new Liquid());
                magaz.AddAsis(new Liquid());
                magaz.AddAsis(new Liquid());
            }
Ejemplo n.º 8
0
        public ActionResult Delete(int id)
        {
            Magazin magazin = db.Magazin.Find(id);

            db.Magazin.Remove(magazin);
            db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 9
0
        public ActionResult Edit(int id)
        {
            Magazin magazin = db.Magazin.Find(id);

            if (!User.IsInRole("Admin"))
            {
                return(HttpNotFound("You don't have acces to modify this "));
            }
            return(View(magazin));
        }
Ejemplo n.º 10
0
 public ActionResult Create(Magazin m)
 {
     if (!ModelState.IsValid)
     {
         return(View("New", m));
     }
     db.Magazin.Add(m);
     db.SaveChanges();
     return(RedirectToAction("Index", "Home"));
 }
Ejemplo n.º 11
0
        public Magazin Post(MagazinDTO value)
        {
            Magazin model = new Magazin()
            {
                Nume   = value.Nume,
                Adresa = value.Adresa
            };

            return(IMagazinRepository.Create(model));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("Id,Cod,Nume,Locatie")] Magazin magazin)
        {
            if (ModelState.IsValid)
            {
                _context.Add(magazin);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(magazin));
        }
Ejemplo n.º 13
0
        public ActionResult Update(Magazin m)
        {
            if (!ModelState.IsValid)
            {
                return(View("Edit", m));
            }
            Magazin magazin = db.Magazin.Single(s => s.MagazinId == m.MagazinId);

            magazin.DenumireMagazin = m.DenumireMagazin;
            magazin.Oras            = m.Oras;
            db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 14
0
        public Magazin Put(int id, MagazinDTO value)
        {
            Magazin model = IMagazinRepository.Get(id);

            if (value.Nume != null)
            {
                model.Nume = value.Nume;
            }

            if (value.Adresa != null)
            {
                model.Adresa = value.Adresa;
            }

            return(IMagazinRepository.Update(model));
        }
Ejemplo n.º 15
0
        public void MainTesting()
        {
            int testVar;

            System.Console.WriteLine("Presupun ca asa se face");
            Singleton_P singleton_P = Singleton_P.GiveInstance();
            Singleton_P anotherTry  = Singleton_P.GiveInstance();

            testVar = singleton_P.giveSomeMaths();
            System.Console.Write(testVar);
            testVar = anotherTry.giveSomeMaths();
            System.Console.Write(testVar);
            bool checkMyWord = Algorithms.VerifyIfUnique("abcdfh");

            System.Console.WriteLine(checkMyWord);
            System.Console.WriteLine("Awaiting input");
            System.Console.WriteLine(Operations.addNumbers(7, 1));
            Operations.printMessage("practice makes perfect son!");
            Notifier     centralPriceUnit = new Notifier();
            List <Shops> ShopsList        = new List <Shops>();

            for (int i = 0; i < 5; i++)
            {
                ShopsList.Add(new Shops());
            }
            ShopsList.ElementAt(0).Name = "Profi";
            ShopsList.ElementAt(1).Name = "Lidl";
            ShopsList.ElementAt(2).Name = "ABC";
            ShopsList.ElementAt(3).Name = "Auchan";
            ShopsList.ElementAt(4).Name = "Jumbo";

            foreach (var ob in ShopsList)
            {
                centralPriceUnit.registerObserver(ob);
            }
            centralPriceUnit.updatePrice(722);

            Bar     bar       = new Bar();
            Magazin magazin   = new Magazin();
            Client  client    = new Client(bar);
            Client  altClient = new Client(magazin);

            client.Request();
            altClient.Request();
            System.Console.ReadLine();
        }
Ejemplo n.º 16
0
        private void PopulateMagazinCostumData(Magazin magazin)
        {
            var allCostume     = _context.Costume;
            var magazinCostume = new HashSet <int>(magazin.MagazinCostume.Select(c => c.CostumID));
            var viewModel      = new List <MagazinCostumData>();

            foreach (var costum in allCostume)
            {
                viewModel.Add(new MagazinCostumData
                {
                    CostumID  = costum.ID,
                    Denumire  = costum.Denumire,
                    IsMagazin = magazinCostume.Contains(costum.ID)
                });
            }
            ViewData["Costume"] = viewModel;
        }
Ejemplo n.º 17
0
        public void Test_UpdateComponent_MakeReload()
        {
            TypesWeapon typesWeapon           = TypesWeapon.Gun;
            int         bullet_In_Magazine    = 8;
            int         duration_Magazine     = 300;
            int         duration_betweenShots = 50;

            var model  = new MockRoyalGameModel();
            var player = new MockPlayer()
            {
                Model = model
            };
            var weapon = new Weapon(model, TypesGameObject.Weapon, TypesBehaveObjects.Active, TypesWeapon.Gun);

            weapon.Owner = player;

            Magazin magazin = new Magazin(weapon, typesWeapon, duration_betweenShots, duration_Magazine, bullet_In_Magazine);

            weapon.Components.Add(magazin);
            weapon.Setup();

            Assert.IsNotNull(magazin.GetBullet());
            player.Update_MakeReloadWeapon(new MakeReloadWeapon(weapon.ID));                    // игров собирается выполнить перезарядку
            Assert.IsNull(magazin.GetBullet());

            weapon.Update(new TimeQuantPassed(duration_Magazine - 1));
            Assert.IsNull(magazin.GetBullet());

            weapon.Update(new TimeQuantPassed(1));
            Assert.IsNotNull(magazin.GetBullet());

            var outMgs = model.outgoingMessages;

            Assert.IsTrue(outMgs.Dequeue().Count == 7);

            var msg_startReload    = outMgs.Dequeue();
            var msg_ChangeBullet_1 = outMgs.Dequeue();
            var mgs_endReload      = outMgs.Dequeue();
            var msg_ChangeBullet_2 = outMgs.Dequeue();

            Assert.IsTrue(msg_startReload.StartOrEnd == true);
            Assert.IsTrue(msg_ChangeBullet_1.Count == 8);
            Assert.IsTrue(mgs_endReload.StartOrEnd == false);
            Assert.IsTrue(msg_ChangeBullet_2.Count == 7);
        }
Ejemplo n.º 18
0
        public EchipamentDetailsDTO Get(int id)
        {
            Echipament           Echipament   = IEchipamentRepository.Get(id);
            EchipamentDetailsDTO MyEchipament = new EchipamentDetailsDTO()
            {
                NumeEchipament = Echipament.NumeEchipament,
                Pret           = Echipament.Pret,
                Descriere      = Echipament.Descriere,
                AnAparitie     = Echipament.AnAparitie,
                Specificatii   = Echipament.Specificatii,
                ProducatorId   = Echipament.ProducatorId,
                img            = Echipament.img
            };

            IEnumerable <EchipamentCategorie> MyEchipamentCategories = IEchipamentCategorieRepository.GetAll().Where(x => x.EchipamentId == Echipament.Id);

            if (MyEchipamentCategories != null)
            {
                List <string> CategorieNumeList = new List <string>();
                foreach (EchipamentCategorie myechipamentCategorie in MyEchipamentCategories)
                {
                    Categorie myCategorie = ICategorieRepository.GetAll().SingleOrDefault(X => X.Id == myechipamentCategorie.CategorieId);
                    CategorieNumeList.Add(myCategorie.NumeCategorie);
                }
                MyEchipament.NumeCategorie = CategorieNumeList;
            }

            IEnumerable <MagazinEchipament> MyMagazinEchipaments = IMagazinEchipamentRepository.GetAll().Where(x => x.EchipamentId == Echipament.Id);

            if (MyMagazinEchipaments != null)
            {
                List <string> MagazinNumeList = new List <string>();
                foreach (MagazinEchipament mymagazinEchipament in MyMagazinEchipaments)
                {
                    Magazin myMagazin = IMagazinRepository.GetAll().SingleOrDefault(X => X.Id == mymagazinEchipament.MagazinId);
                    MagazinNumeList.Add(myMagazin.Nume);
                }
                MyEchipament.Nume = MagazinNumeList;
            }
            return(MyEchipament);
        }
Ejemplo n.º 19
0
        private void UpdateMagazinCostume(string[] selectedCostume, Magazin magazinToUpdate)
        {
            if (selectedCostume == null)
            {
                magazinToUpdate.MagazinCostume = new List <MagazinCostum>();
                return;
            }
            var selectedCostumeHS = new HashSet <string>(selectedCostume);
            var magazinCostume    = new HashSet <int>
                                        (magazinToUpdate.MagazinCostume.Select(c => c.Costum.ID));

            foreach (var costum in _context.Costume)
            {
                if (selectedCostumeHS.Contains(costum.ID.ToString()))
                {
                    if (!magazinCostume.Contains(costum.ID))
                    {
                        magazinToUpdate.MagazinCostume.Add(new MagazinCostum
                        {
                            MagazinID =
                                magazinToUpdate.ID,
                            CostumID = costum.ID
                        });
                    }
                }
                else
                {
                    if (magazinCostume.Contains(costum.ID))
                    {
                        MagazinCostum costumToRemove = magazinToUpdate.MagazinCostume.FirstOrDefault(i
                                                                                                     => i.CostumID == costum.ID);
                        _context.Remove(costumToRemove);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public Magazin Delete(int id)
        {
            Magazin model = IMagazinRepository.Get(id);

            return(IMagazinRepository.Delete(model));
        }
        public static void Initialize(Shop context)
        {
            context.Database.EnsureCreated();
            if (context.Costume.Any())
            {
                return; // BD a fost creata anterior
            }
            var Costume = new Costum[]
            {
                new Costum {
                    Denumire = "SpiderMan", Categorie = "Barbati", Pret = Decimal.Parse("150")
                },
                new Costum {
                    Denumire = "Batman", Categorie = "Copii", Pret = Decimal.Parse("75")
                },
                new Costum {
                    Denumire = "Harley Quen", Categorie = "Femei", Pret = Decimal.Parse("110")
                }
            };

            foreach (Costum b in Costume)
            {
                context.Costume.Add(b);
            }
            context.SaveChanges();
            var customers = new Customer[]
            {
                new Customer {
                    CustomerID = 1050, Name = "PopescuMarcela", BirthDate = DateTime.Parse("1979-09-01")
                },
                new Customer {
                    CustomerID = 1045, Name = "MihailescuCornel", BirthDate = DateTime.Parse("1969-07-08")
                },
            };

            foreach (Customer c in customers)
            {
                context.Customers.Add(c);
            }
            context.SaveChanges();
            var orders = new Order[]
            {
                new Order {
                    CostumID = 1, CustomerID = 1050, OrderDate = DateTime.Parse("2020-12-20")
                },
                new Order {
                    CostumID = 3, CustomerID = 1045, OrderDate = DateTime.Parse("2020-12-21")
                },
                new Order {
                    CostumID = 1, CustomerID = 1045, OrderDate = DateTime.Parse("2020-12-20")
                },
                new Order {
                    CostumID = 2, CustomerID = 1050, OrderDate = DateTime.Parse("2020-12-25")
                },
            };

            foreach (Order e in orders)
            {
                context.Orders.Add(e);
            }
            context.SaveChanges();

            var magazine = new Magazin[]
            {
                new Magazin {
                    MagazinName = "MagazinBlaj", Adress = "Str. Al.Golescu, nr.11"
                },
                new Magazin {
                    MagazinName = "MgazinCluj", Adress = "Str.Hasdeu,nr.15"
                },
            };

            foreach (Magazin p in magazine)
            {
                context.Magazine.Add(p);
            }
            context.SaveChanges();
            var magazincostume = new MagazinCostum[]
            {
                new MagazinCostum {
                    CostumID = Costume.Single(c => c.Denumire == "Spiderman").ID, MagazinID = magazine.Single(i => i.MagazinName == "MagazinBlaj").ID
                },
                new MagazinCostum {
                    CostumID = Costume.Single(c => c.Denumire == "Batman").ID, MagazinID = magazine.Single(i => i.MagazinName == "MagazinCluj").ID
                },
                new MagazinCostum {
                    CostumID = Costume.Single(c => c.Denumire == "Harley Quen").ID, MagazinID = magazine.Single(i => i.MagazinName == "MagazinCluj").ID
                },
            };

            foreach (MagazinCostum pb in magazincostume)
            {
                context.MagazinCostume.Add(pb);
            }
            context.SaveChanges();
        }
Ejemplo n.º 22
0
 private void Manual(Magazin magazin, Liquid e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 23
0
 public Ariel(string _name, Magazin pub)
 {
     name      = _name;
     stripping = 2;
     powder    = 7;
 }
Ejemplo n.º 24
0
        public async Task <IActionResult> AddDepartment([Bind("Id")] Departament departament, Magazin magazin)
        {
            if (ModelState.IsValid)
            {
                _context.Add(departament);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(magazin));
        }
Ejemplo n.º 25
0
 public Liquid(string nameOfLiquid, Magazin magazin)
 {
     this.nameOfLiquid = nameOfLiquid;
     this.magazin      = magazin;
 }
Ejemplo n.º 26
0
 public Magazin Update(Magazin Magazin)
 {
     _context.Entry(Magazin).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     _context.SaveChanges();
     return(Magazin);
 }
Ejemplo n.º 27
0
 public void Test_CreateMagazin()
 {
     Magazin magazin = new Magazin(new StubWeapon(), TypesWeapon.Gun, 500, 3000, 8);
 }
Ejemplo n.º 28
0
 public void Test_ErrorCreateMagazin()
 {
     Magazin magazin = new Magazin(null, TypesWeapon.Gun, 500, 3000, 8);
 }
Ejemplo n.º 29
0
        public void Test_StateMagazin()
        {
            Magazin magazin = new Magazin(new StubWeapon(), TypesWeapon.Gun, 500, 3000, 8);

            Assert.IsNotNull(magazin.State);
        }