Example #1
0
        public ActionResult Ekle()
        {
            var urun = new tbl_Urun();

            ViewBag.Kategori_ID = new SelectList(uow.GetRepository <tbl_Kategori>().GetAll(), "Kategori_Id", "Kategori");
            ViewBag.Marka_ID    = new SelectList(uow.MarkaRepository.GetAll(), "Marka_Id", "Marka_Adi");
            return(View(urun));
        }
        public ActionResult UrunGuncelle(tbl_Urun p1)
        {
            var urun = db.tbl_Urun.Find(p1.UrunId);

            urun.UrunNo    = p1.UrunNo;
            urun.UrunAdi   = p1.UrunAdi;
            urun.UrunFiyat = p1.UrunFiyat;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult UrunEkle(tbl_Urun u1)
 {
     if (!ModelState.IsValid)
     {
         return(View("Index"));
     }
     db.tbl_Urun.Add(u1);
     db.SaveChanges();
     return(View("UrunEkle"));
 }
        public ActionResult FaturaBilgiEkle(tbl_FaturaBilgi fb1)
        {
            DataContext dtb = new DataContext();
            tbl_Urun    Fb  = db.tbl_Urun.Where(k => k.UrunId == fb1.UrunId).FirstOrDefault();

            fb1.tbl_Urun = Fb;

            db.tbl_FaturaBilgi.Add(fb1);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
        public void Sil(int id)
        {
            tbl_Urun urunvarMi = new tbl_Urun();
            var      marka     = uow.MarkaRepository.GetById(id);

            if (marka != null)
            {
                uow.MarkaRepository.Delete(marka);
                uow.SaveChanges();
            }
        }
        private void StokSil(Cart cart)
        {
            foreach (var cartline in cart.CartLines)
            {
                // int sayi = cartline.Adet;
                tbl_Urun satilanurun = new tbl_Urun();
                satilanurun      = cartline.Urun;
                satilanurun.Stok = satilanurun.Stok - cartline.Adet;
                var urun = uow.UrunRepository.Get(i => i.Urun_Id == satilanurun.Urun_Id);
                urun.Stok = satilanurun.Stok;
                uow.UrunRepository.Update(urun);

                uow.SaveChanges();
            }
        }
Example #7
0
        public void AddProduct(tbl_Urun product, int adet)
        {
            var line = _cartlines.FirstOrDefault(i => i.Urun.Urun_Id == product.Urun_Id);

            if (line == null)
            {
                _cartlines.Add(new Cartline
                {
                    Urun = product,
                    Adet = adet
                });
            }
            else
            {
                line.Adet += adet;
            }

            uow.GetRepository <tbl_Sepet>().Add(new tbl_Sepet
            {
                Urun_ID = product.Urun_Id,
                Adet    = adet
            });
            uow.SaveChanges();

            //var varsa = uow.GetRepository<tbl_Satin_Alma>().Get(i => i.Urun_ID == product.Urun_Id);
            //if (varsa != null)
            //{


            //    tbl_Satin_Alma sa = new tbl_Satin_Alma();
            //    sa.Satis_Id = varsa.Satis_Id;
            //    sa.Adet = varsa.Adet + adet;
            //    sa.Urun_ID = varsa.Urun_ID;
            //    //  db.tbl_Satin_Alma.Attach(sa);

            //  //  db.Entry(sa).State = EntityState.Modified;
            //    db.SaveChanges();
            //    // db.SaveChanges();
            //   uow.GetRepository<tbl_Satin_Alma>().Update(sa);
            //    uow.SaveChanges();
            //}
            //else
            //{

            //  }
        }
        public ActionResult UrunIndirim(tbl_Urun urun, decimal indirim)
        {
            if (urun.Urun_Id != 0)
            {
                var IndirimYapilacakUrun = uow.UrunRepository.Get(x => x.Urun_Id == urun.Urun_Id);
                if (IndirimYapilacakUrun.Indirim_Oranı == 1)
                {
                    IndirimYapilacakUrun.Indirim_Oranı += indirim;
                }
                else
                {
                    IndirimYapilacakUrun.Indirim_Oranı += indirim;
                }

                uow.SaveChanges();
                ViewBag.mesaj = "indirim işlemi tamamlandı";
            }
            return(View("Index"));
        }
Example #9
0
        public ActionResult Ekle(tbl_Urun urun, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file.ContentLength > 0 || file != null)
                {
                    var extention = Path.GetExtension(file.FileName);
                    if (extention == ".jpg" || extention == ".png")
                    {
                        var filename = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/upload"), filename);
                        file.SaveAs(path);


                        uow.UrunRepository.Add(new tbl_Urun
                        {
                            Urun_Adi      = urun.Urun_Adi,
                            Fiyat         = urun.Fiyat,
                            Aciklama      = urun.Aciklama,
                            Kategori_ID   = urun.Kategori_ID,
                            Seri_No       = urun.Seri_No,
                            Marka_ID      = urun.Marka_ID,
                            Stok          = urun.Stok,
                            Resim_URL     = file.FileName,
                            Indirim_Oranı = 1
                        });
                        uow.GetRepository <tbl_Yildiz>().Add(new tbl_Yildiz
                        {
                            Urun_Id = urun.Urun_Id,
                            Yildiz  = 0
                        });
                        uow.SaveChanges();
                        return(RedirectToAction("Liste"));
                    }
                }
            }
            ViewBag.Kategori_ID = new SelectList(uow.GetRepository <tbl_Kategori>().GetAll(), "Kategori_Id", "Kategori");
            ViewBag.Marka_Id    = new SelectList(uow.MarkaRepository.GetAll(), "Marka_Id", "Marka_Adi");
            return(View(urun));
        }
Example #10
0
        public ActionResult Duzenle(tbl_Urun urun, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file.ContentLength > 0 || file != null)
                {
                    var extention = Path.GetExtension(file.FileName);
                    if (extention == ".jpg" || extention == ".png" || extention == ".JPG" || extention == ".PNG")
                    {
                        var filename = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/upload"), filename);
                        file.SaveAs(path);
                        //var urun = uow.UrunRepository.Get(i => i.Urun_Id == satilanurun.Urun_Id);
                        //urun.Stok = satilanurun.Stok;
                        //uow.UrunRepository.Update(urun);


                        var urunduzenle = new tbl_Urun
                        {
                            Urun_Id     = urun.Urun_Id,
                            Urun_Adi    = urun.Urun_Adi,
                            Fiyat       = urun.Fiyat,
                            Aciklama    = urun.Aciklama,
                            Kategori_ID = urun.Kategori_ID,
                            Seri_No     = urun.Seri_No,
                            Marka_ID    = urun.Marka_ID,
                            Stok        = urun.Stok,
                            Resim_URL   = file.FileName
                        };
                        uow.UrunRepository.Update(urunduzenle);
                        uow.SaveChanges();
                        return(RedirectToAction("Liste"));
                    }
                }
            }
            ViewBag.Kategori_ID = new SelectList(uow.GetRepository <tbl_Kategori>().GetAll(), "Kategori_Id", "Kategori");
            ViewBag.Marka_Id    = new SelectList(uow.MarkaRepository.GetAll(), "Marka_Id", "Marka_Adi");
            return(View(urun));
        }
Example #11
0
        public ActionResult Ekle()
        {
            var model = new tbl_Urun();

            return(View(model));
        }
Example #12
0
 public void UrunSil(tbl_Urun urun)
 {
     _cartlines.RemoveAll(i => i.Urun.Urun_Id == urun.Urun_Id);
 }