Exemplo n.º 1
0
        public IActionResult Show(int id)
        {
            OneModel obj = new OneModel();

            obj.country = db.countries.FirstOrDefault(u => u.Id == id);
            return(View(obj.country));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            // database gave us this:
            OneModel model = new OneModel {
                Name = "One Thing"
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public IActionResult Delete(int id)
        {
            OneModel obj = new OneModel();

            obj.country = db.countries.FirstOrDefault(u => u.Id == id);
            db.countries.Remove(obj.country);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        public void Create_OneToManyModel([Values("EF", "ORMLite", "ADO")] string impl)
        {
            var many1 = new ManyModel { Many = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() };
            var many2 = new ManyModel { Many = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() };
            var one = new OneModel
            {
                One = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(),
                Many = new List<ManyModel>(new ManyModel[] { many1, many2 })
            };

            CreateOneModelImpl(impl).Create(one);

            Expect(one.Id, Is.GreaterThan(0));
        }
Exemplo n.º 5
0
        public IActionResult Categorii(int id)// functia pentru sortare dupa categorii
        {
            ViewModel     obj   = new ViewModel();
            OneModel      A     = new OneModel();
            List <Produs> ListA = new List <Produs>();

            obj.viewProdus = db.Produse.ToList();
            for (int i = 0; i < obj.viewProdus.Count(); i++)
            {
                if (obj.viewProdus[i].categoryID == id)
                {
                    A.produs = obj.viewProdus[i];
                    ListA.Add(A.produs);
                }
            }
            logger.LogInformation("Metoda Categorii() a fost accesata");
            return(View(ListA));
        }
Exemplo n.º 6
0
        public IActionResult Favourite()  // Pagina cu produsele favorite
        {
            ViewModel     obj   = new ViewModel();
            OneModel      A     = new OneModel();
            List <Produs> ListA = new List <Produs>();

            obj.viewProdus = db.Produse.ToList();
            for (int i = 0; i < obj.viewProdus.Count(); i++)
            {
                if (obj.viewProdus[i].Favourite == true)
                {
                    A.produs = obj.viewProdus[i];
                    ListA.Add(A.produs);
                }
            }
            logger.LogInformation("Metoda Favourite() a fost accesata");
            return(View(ListA));
        }
Exemplo n.º 7
0
 public ActionResult Index(OneModel Model)
 {
     // Save to database
     return(RedirectToAction("Index"));
 }
Exemplo n.º 8
0
        public void CRUD_OneToManyModel([Values("EF", "ORMLite", "ADO")] string impl)
        {
            var repo = CreateOneModelImpl(impl);

            var many1 = new ManyModel { Many = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() };
            var many2 = new ManyModel { Many = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() };
            var one = new OneModel
            {
                One = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(),
                Many = new List<ManyModel>(new ManyModel[] { many1, many2 })
            };

            repo.Create(one);

            var r = repo.FindById(one.Id);

            Expect(r.Many.Select(m => m.Id), EquivalentTo(one.Many.Select(m => m.Id)));

            r.One += "_updated_" + impl;
            r.Many.ForEach((m) => { m.Many += "_update_" + impl; });

            repo.Update(r);

            repo.Delete(r);

            Expect(r.Id, Is.GreaterThan(0).And.EqualTo(one.Id));
        }