public IActionResult Index(Kullanici model)
        {
            ETicaretDbContext tablo = new ETicaretDbContext();
            Kullanici         k     = tablo.Kullanicis.FirstOrDefault(x => x.EMail == model.EMail);

            //Login kontrol işlemleri ve yönlendirmeler
            if (k != null)
            {
                HttpContext.Session.SetString("username", k.Ad);
                HttpContext.Session.SetString("e-Mail", k.EMail);
                k.RememberMe = model.RememberMe;
                tablo.SaveChanges();
                if (k.RememberMe)
                {
                    CookieOptions option = new CookieOptions();
                    Response.Cookies.Append("username", k.EMail, option);
                    Response.Cookies.Append("password", k.Sifre, option);
                }
                return(Redirect("~/Home/Index"));
            }
            else
            {
                ViewBag.Mesaj = "Geçersiz bilgiler, tekrar deneyiniz";
            }
            return(View());
        }
        public IActionResult UyeOl(Kullanici c)
        {
            if (ModelState.IsValid)
            {
            }

            //veritabanına yazdır
            if (c.Id > 0)
            {
                //update
            }
            else
            {
                ETicaretDbContext tablo = new ETicaretDbContext();
                Kullanici         c2    = new Kullanici();
                c2.Ad         = c.Ad;
                c2.Adres      = c.Adres;
                c2.EMail      = c.EMail;
                c2.Sifre      = c.Sifre;
                c2.RememberMe = false;
                c2.Telefon    = c.Telefon;
                tablo.Add(c2);
                tablo.SaveChanges();
            }

            return(View());
        }
예제 #3
0
        public ActionResult SiparisEkle( )
        {
            string            email = HttpContext.Session.GetString("e-Mail");
            ETicaretDbContext tablo = new ETicaretDbContext();
            int id = tablo.Kullanicis.FirstOrDefault(x => x.EMail == email).Id;

            return(View());
        }
        public ActionResult Update(Category c)
        {

            ETicaretDbContext tablo = new ETicaretDbContext();
            var category = tablo.Categories.FirstOrDefault(x => x.Id == c.Id);
            category.Ad = c.Ad;
            tablo.SaveChanges();
            return View();
        }
예제 #5
0
        public IActionResult Index()
        {
            ViewBag.Username = HttpContext.Session.GetString("username");
            ETicaretDbContext tablo = new ETicaretDbContext();

            ViewBag.liste1 = tablo.Categories.Select(x => x.Ad).ToList();
            ViewBag.liste2 = tablo.Uruns.ToList();
            return(View());
        }
예제 #6
0
        public IActionResult AdresGir()
        {
            //adres sayfası açılır
            ETicaretDbContext tablo = new ETicaretDbContext();
            int K_id  = Convert.ToInt32(HttpContext.Request.Query["id"]);
            var Adres = tablo.Adres.Where(x => x.KullaniciId == K_id).ToList();

            ViewBag.KListe = Adres;
            return(View());
        }
        public ActionResult Delete()
        {
            int id = Convert.ToInt32(Request.Query["id"]);

            ETicaretDbContext tablo = new ETicaretDbContext();
            var category = tablo.Categories.FirstOrDefault(x => x.Id == id);
            tablo.Categories.Remove(category);
            tablo.SaveChanges();

            return RedirectToAction("Index");
        }
예제 #8
0
        public IActionResult Sepetim()
        {
            ViewBag.Username = HttpContext.Session.GetString("username");
            string            ad    = ViewBag.Username;
            ETicaretDbContext tablo = new ETicaretDbContext();
            int id        = tablo.Kullanicis.FirstOrDefault(x => x.Ad == ad).Id;
            var userSepet = tablo.Sepets.Include(x => x.Urun).Include(x => x.Kullanici).Where(x => x.KullaniciId == id).ToList();

            ViewBag.liste1 = userSepet;
            return(View());
        }
예제 #9
0
        public ActionResult Update(Urun c)
        {
            ETicaretDbContext tablo = new ETicaretDbContext();
            var urun = tablo.Uruns.FirstOrDefault(x => x.Id == c.Id);

            urun.Id       = c.Id;
            urun.Ad       = c.Ad;
            urun.Fiyat    = c.Fiyat;
            urun.ImageUrl = c.ImageUrl;
            tablo.SaveChanges();
            return(View());
        }
예제 #10
0
        public IActionResult Index()
        {
            ETicaretDbContext tablo = new ETicaretDbContext();
            var categories = tablo.Categories.ToList();

            var categoryVMs = categories.Select(x => new Category()
            {
                Id = x.Id,
                Ad = x.Ad
            }).ToList();
            return View(categoryVMs);
        }
예제 #11
0
        public ActionResult Update()
        {
            int id = Convert.ToInt32(Request.Query["id"]);
            ETicaretDbContext tablo = new ETicaretDbContext();
            var category = tablo.Categories.FirstOrDefault(x => x.Id == id);

            Category vm = new Category()
            {
                Id = category.Id,
                Ad = category.Ad
            };

            return View(vm);
        }
예제 #12
0
        public IActionResult Index()
        {
            ETicaretDbContext tablo = new ETicaretDbContext();
            var uruns = tablo.Uruns.ToList();

            var urunvms = uruns.Select(x => new Urun()
            {
                Id       = x.Id,
                Ad       = x.Ad,
                Fiyat    = x.Fiyat,
                ImageUrl = x.ImageUrl
            }).Skip(10).Take(5).ToList();

            return(View(urunvms));
        }
예제 #13
0
        public IActionResult AdetAzalt()
        {
            int urunid = Convert.ToInt32(HttpContext.Request.Query["id"]);

            ViewBag.Username = HttpContext.Session.GetString("username");
            string            ad    = ViewBag.Username;
            ETicaretDbContext tablo = new ETicaretDbContext();
            int id = tablo.Kullanicis.FirstOrDefault(x => x.Ad == ad).Id;
            var guncellenecekUrun = tablo.Sepets.Include(x => x.Urun).Include(x => x.Kullanici).Where(x => x.KullaniciId == id && x.UrunId == urunid).FirstOrDefault();

            guncellenecekUrun.UrunAdet--;
            tablo.SaveChanges();

            return(Redirect("/Urun/Sepetim"));
        }
예제 #14
0
        public IActionResult SepeteEkle()
        {
            string            KullaniciEmail = HttpContext.Session.GetString("e-Mail");
            ETicaretDbContext tablo          = new ETicaretDbContext();
            int    kId       = tablo.Kullanicis.FirstOrDefault(x => x.EMail == KullaniciEmail).Id;
            string urunid    = HttpContext.Request.Query["id"];
            string urunfiyat = HttpContext.Request.Query["fiyat"];
            Sepet  sepet     = new Sepet();

            sepet.KullaniciId = kId;
            sepet.UrunAdet    = 1;
            sepet.UrunId      = Convert.ToInt32(urunid);
            tablo.Sepets.Add(sepet);
            tablo.SaveChanges();
            return(Redirect("/Home/Index"));
        }
예제 #15
0
        public ActionResult Update()
        {
            int id = Convert.ToInt32(Request.Query["id"]);
            ETicaretDbContext tablo = new ETicaretDbContext();
            var urun = tablo.Uruns.FirstOrDefault(x => x.Id == id);

            Urun vm = new Urun()
            {
                Id       = urun.Id,
                Ad       = urun.Ad,
                Fiyat    = urun.Fiyat,
                ImageUrl = urun.ImageUrl
            };

            return(View(vm));
        }
예제 #16
0
        public ActionResult YeniAdresEkle(Adres k)
        {
            //yeni adres eklenir
            string            email       = HttpContext.Session.GetString("e-Mail");
            string            kullaniciAd = HttpContext.Session.GetString("username");
            ETicaretDbContext tablo       = new ETicaretDbContext();
            int   id = tablo.Kullanicis.FirstOrDefault(x => x.EMail == email).Id;
            Adres a  = new Adres();

            a.KullaniciId = id;
            a.KullaniciAd = kullaniciAd;
            a.YeniAdres   = k.YeniAdres;
            a.Telefon     = k.Telefon;
            a.EMail       = k.EMail;
            a.AdresBaslik = k.AdresBaslik;
            tablo.Adres.Add(a);
            tablo.SaveChanges();
            return(Redirect("/Urun/AdresGir?id=" + id));
        }
예제 #17
0
        public IActionResult VeriEkle()
        {
            ETicaretDbContext tablo = new ETicaretDbContext();
            Category          c     = new Category();

            c.Ad = "Telefon";
            Category c2 = new Category();

            c2.Ad = "Bilgisayar";

            tablo.Add(c);
            tablo.Add(c2);
            tablo.SaveChanges();

            for (int i = 0; i < 10; i++)
            {
                Urun u = new Urun();
                u.Ad         = "İphone " + i;
                u.KategoriId = c.Id;
                u.Fiyat      = 1000 * (i + 1);
                u.ImageUrl   = "https://store.storeimages.cdn-apple.com/4668/as-images.apple.com/is/iphone-12-black-select-2020?wid=940&hei=1112&fmt=png-alpha&qlt=80&.v=1604343702000";
                tablo.Uruns.Add(u);
            }

            for (int i = 0; i < 10; i++)
            {
                Urun u = new Urun();
                u.Ad         = "Macbook " + i;
                u.KategoriId = c2.Id;
                u.Fiyat      = 2000 * (i + 1);
                u.ImageUrl   = "https://store.storeimages.cdn-apple.com/4668/as-images.apple.com/is/mbp-spacegray-select-202011?wid=452&hei=420&fmt=jpeg&qlt=95&op_usm=0.5,0.5&.v=1603406905000";

                tablo.Uruns.Add(u);
            }
            tablo.SaveChanges();


            return(View());
        }
예제 #18
0
        public IActionResult KategoryEkle(Category c)
        {

            if (ModelState.IsValid)
            {

            }

            //veritabanına yazdır
            if (c.Id > 0)
            {
                //update
            }
            else
            {
                ETicaretDbContext tablo = new ETicaretDbContext();
                Category c2 = new Category();
                c2.Ad = c.Ad;
                tablo.Add(c2);
                tablo.SaveChanges();
            }

            return View();
        }
예제 #19
0
        public IActionResult UrunEkle(Urun c)
        {
            if (ModelState.IsValid)
            {
            }

            //veritabanına yazdır
            if (c.Id > 0)
            {
                //update
            }
            else
            {
                ETicaretDbContext tablo = new ETicaretDbContext();
                Urun c2 = new Urun();
                c2.Ad       = c.Ad;
                c2.Fiyat    = c.Fiyat;
                c2.ImageUrl = c.ImageUrl;
                tablo.Add(c2);
                tablo.SaveChanges();
            }

            return(View());
        }
예제 #20
0
 public GenericRepository(ETicaretDbContext db)
 {
     this.db = db;
     table   = db.Set <T>();
 }
예제 #21
0
 public GenericRepository()
 {
     this.db = new ETicaretDbContext();
     table   = db.Set <T>();
 }