public ActionResult UrunBazliIndirim()
        {
            var model = uow.UrunRepository.GetAll().ToList();

            ViewBag.Urun_ID = new SelectList(uow.GetRepository <tbl_Urun>().GetAll(), "Urun_Id", "Urun_Adi");
            return(View("UrunBazliIndirim", model));
        }
Exemplo n.º 2
0
 public bool Update(CategoryModel entity)
 {
     try
     {
         using (StockDbContext context = new StockDbContext())
             using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
             {
                 var category = unitofwork.GetRepository <Category>().GetById(entity.CategoryId);
                 category.CategoryName = entity.CategoryName;
                 category.Description  = entity.Description;
                 unitofwork.GetRepository <Category>().Update(category);
                 int saveCount = unitofwork.SaveChanges();
                 if (saveCount == 0)
                 {
                     return(false);
                 }
                 return(true);
             }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         throw;
     }
 }
        private void SiparisKaydet(Cart cart)
        {
            var     girenkullanici = HttpContext.User.Identity.Name;
            var     kullanici      = uow.GetRepository <tbl_Kullanici>().Get(i => i.Kullanici_Adi == girenkullanici);
            Siparis siparis        = new Siparis();

            siparis.SiparisNumarasi = "O" + (new Random()).Next(1000000, 9999999).ToString();
            siparis.ToplamTutar     = cart.Total();
            siparis.KullaniciId     = kullanici.Kullanici_Id;
            siparis.SiparisTarihi   = DateTime.Now;
            siparis.SiparisDetay    = new List <SiparisDetay>();
            foreach (var sd in cart.CartLines)
            {
                SiparisDetay siparisdetay = new SiparisDetay();
                siparisdetay.Adet              = sd.Adet;
                siparisdetay.Fiyat             = (sd.Urun.Fiyat * (decimal)sd.Adet);
                siparisdetay.UrunId            = sd.Urun.Urun_Id;
                siparisdetay.UrunSiparisTarihi = DateTime.Now;
                siparis.SiparisDetay.Add(siparisdetay);
            }



            uow.GetRepository <Siparis>().Add(siparis);
            uow.SaveChanges();
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        // GET: Profil
        public ActionResult Siparislerim()
        {
            var kullanici  = HttpContext.User.Identity.Name;
            var kulid      = uow.GetRepository <tbl_Kullanici>().Get(i => i.Kullanici_Adi == kullanici);
            var siparisler = uow.GetRepository <Siparis>().GetAll().Where(i => i.KullaniciId == kulid.Kullanici_Id)
                             .OrderByDescending(i => i.SiparisId);

            return(View(siparisler));
        }
Exemplo n.º 6
0
        // GET: Admin/Duyuru
        public ActionResult Index()
        {
            var duyuru = uow.GetRepository <tbl_Duyuru>().GetById(1);

            if (duyuru == null)
            {
                HttpNotFound();
            }

            return(View(duyuru));
        }
        public ActionResult Login(tbl_Kullanici kullanici)
        {
            var Girenkullanici = uow.GetRepository <tbl_Kullanici>().Get(x => x.Eposta == kullanici.Eposta && x.Sifre == kullanici.Sifre);

            if (Girenkullanici != null)
            {
                FormsAuthentication.SetAuthCookie(Girenkullanici.Kullanici_Adi, false);
                return(RedirectToAction("Anasayfa", "Anasayfa"));
            }
            else
            {
                ViewBag.mesaj = "Geçersiz kullanıcı adı veya şifre";
                return(View());
            }
        }
Exemplo n.º 8
0
        public ActionResult MesajAt(tbl_Mesaj mesaj)
        {
            var Kullanici = uow.GetRepository <tbl_Kullanici>()
                            .Get(x => x.Kullanici_Adi == HttpContext.User.Identity.Name);
            var body = new StringBuilder();

            if (HttpContext.User.Identity.Name != "")
            {
                body.AppendLine("Kullanıcı mesajı");
                body.AppendLine("Eposta: " + Kullanici.Eposta);
                body.AppendLine("isim: " + Kullanici.Ad + " " + Kullanici.Soyad);
            }
            else
            {
                body.AppendLine("Ziyaretçi mesajı");
                body.AppendLine("Eposta: " + mesaj.Eposta);
                body.AppendLine("isim: " + mesaj.AdSoyad);
            }
            body.AppendLine("Konu: " + mesaj.Konu);
            body.AppendLine("içerik: " + mesaj.Icerik);
            Eposta.SendMail(body.ToString());
            ViewBag.succes = true;

            return(View("Index"));
        }
        // GET: AnaSayfa
        public ActionResult Anasayfa(int page = 1, int pageSize = 12)
        {
            tbl_Duyuru popup   = GetPopup();
            var        urunler = uow.GetRepository <tbl_Urun>().GetAll().ToList();

            ViewBag.Duyuru = uow.GetRepository <tbl_Duyuru>().GetById(1);

            AnasayfaModelView anasayfamodel = new AnasayfaModelView
            {
                Duyuru  = null,
                Urunler = urunler
            };
            PagedList <tbl_Urun> personModel = new PagedList <tbl_Urun>(urunler, page, pageSize);

            return(View(personModel));
        }
Exemplo n.º 10
0
 void Session_Start(object sender, EventArgs e)
 {
     uow.GetRepository <Ziyaretci>().Add(new Ziyaretci
     {
         ZiyaretTarihi = DateTime.Now
     });
     uow.SaveChanges();
 }
Exemplo n.º 11
0
 public EmployeeModel GetById(Guid id)
 {
     using (StockDbContext context = new StockDbContext())
         using (IUnitOfWork unitOfWork = new EfUnitOfWork(context))
         {
             var           employee      = unitOfWork.GetRepository <Employee>().GetById(id);
             EmployeeModel employeeModel = StockMapper.EmployeeModelMap(employee);
             return(employeeModel);
         }
 }
Exemplo n.º 12
0
 public bool Delete(Guid id)
 {
     using (StockDbContext context = new StockDbContext())
         using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
         {
             unitofwork.GetRepository <Employee>().Delete(id);
             int saveCount = unitofwork.SaveChanges();
             if (saveCount == 0)
             {
                 return(false);
             }
             return(true);
         }
 }
Exemplo n.º 13
0
 public bool Delete(EmployeeModel entity)
 {
     using (StockDbContext context = new StockDbContext())
         using (IUnitOfWork unitOfWork = new EfUnitOfWork(context))
         {
             Employee employee = StockMapper.EmployeeMap(entity);
             unitOfWork.GetRepository <Employee>().Delete(employee);
             int saveCount = unitOfWork.SaveChanges();
             if (saveCount == 0)
             {
                 return(false);
             }
             return(true);
         }
 }
Exemplo n.º 14
0
 public bool Delete(OrderModel entity)
 {
     using (StockDbContext context = new StockDbContext())
         using (IUnitOfWork unitOfWork = new EfUnitOfWork(context))
         {
             Order order = StockMapper.OrderMap(entity);
             unitOfWork.GetRepository <Order>().Delete(order);
             int saveCount = unitOfWork.SaveChanges();
             if (saveCount == 0)
             {
                 return(false);
             }
             return(true);
         }
 }
        public ActionResult Liste()
        {
            var kategoriler = uow.GetRepository <tbl_Kategori>().GetAll().ToList();

            if (kategoriler == null)
            {
                HttpNotFound();
            }
            return(PartialView(kategoriler));
        }
        public ActionResult Login(tbl_Kullanici kullanici)
        {
            var admin = uow.GetRepository <tbl_Kullanici>()
                        .Get(k => k.Eposta == kullanici.Eposta && k.Sifre == kullanici.Sifre && k.Rol_ID == 1);

            if (admin != null)
            {
                Session["LogonAdmin"] = admin;
                return(Redirect("/"));
            }
            else
            {
                ViewBag.Error = "kullanıcı ve şifre yanlış";
                return(View());
            }
        }
Exemplo n.º 17
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
            //{

            //  }
        }
Exemplo n.º 18
0
        public List <CategoryModel> GetAlls()
        {
            using (StockDbContext context = new StockDbContext())
                using (IUnitOfWork unitOfWork = new EfUnitOfWork(context))
                {
                    var category = unitOfWork.GetRepository <Category>().GetAll();

                    List <CategoryModel> categoryModels = category.Select(s => new CategoryModel()
                    {
                        CategoryId   = s.CategoryId,
                        CategoryName = s.CategoryName,
                        Description  = s.Description,
                        Picture      = s.Picture
                    }).ToList();

                    return(categoryModels);
                }
        }
Exemplo n.º 19
0
        public bool Delete(CustomerModel entity)
        {
            try
            {
                if (entity != null)
                {
                    using (StockDbContext context = new StockDbContext())
                        using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
                        {
                            Customer customer = new Customer
                            {
                                CustomerId   = Guid.NewGuid(),
                                City         = entity.City,
                                CompanyName  = entity.CompanyName,
                                Address      = entity.Address,
                                Region       = entity.Region,
                                Phone        = entity.Phone,
                                ContactTitle = entity.ContactTitle,
                                ContactName  = entity.ContactName,
                                PostalCode   = entity.PostalCode,
                                Country      = entity.Country,
                                Fax          = entity.Fax,
                            };

                            unitofwork.GetRepository <Customer>().Delete(customer);
                            int saveCount = unitofwork.SaveChanges();
                            if (saveCount == 0)
                            {
                                return(false);
                            }
                            return(true);
                        }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }

            return(true);
        }
Exemplo n.º 20
0
        public Model.Result.CustomerAddResult AddCustomer(CustomerAddRequest request)
        {
            CustomerAddResult result = new CustomerAddResult();

            try
            {
                if (request != null && request.CustomerModel != null)
                {
                    using (StockDbContext context = new StockDbContext())
                        using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
                        {
                            Customer customer = new Customer
                            {
                                CustomerId   = Guid.NewGuid(),
                                City         = request.CustomerModel.City,
                                CompanyName  = request.CustomerModel.CompanyName,
                                Address      = request.CustomerModel.Address,
                                Region       = request.CustomerModel.Region,
                                Phone        = request.CustomerModel.Phone,
                                ContactTitle = request.CustomerModel.ContactTitle,
                                ContactName  = request.CustomerModel.ContactName,
                                PostalCode   = request.CustomerModel.PostalCode,
                                Country      = request.CustomerModel.Country,
                                Fax          = request.CustomerModel.Fax,
                            };
                            unitofwork.GetRepository <Customer>().Add(customer);
                            result.SaveCount = unitofwork.SaveChanges();
                            if (result.SaveCount > 0)
                            {
                                return(result);
                            }
                        }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }

            return(result);
        }
Exemplo n.º 21
0
        TestMethodProductAdd()
        {
            using (StockDbContext context = new StockDbContext())
                using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
                {
                    Product product = new Product()
                    {
                        ProductId       = Guid.NewGuid(),
                        Discontinued    = true,
                        ProductName     = "At",
                        SupplierId      = Guid.NewGuid(),
                        CategoryId      = Guid.NewGuid(),
                        UnitPrice       = 5,
                        UnitsInStock    = 15,
                        QuantityPerUnit = "kestanesi",
                    };

                    unitofwork.GetRepository <Product>().Add(product);
                    unitofwork.SaveChanges();
                }
        }
Exemplo n.º 22
0
 public CustomerModel GetById(Guid id)
 {
     using (StockDbContext context = new StockDbContext())
         using (IUnitOfWork unitOfWork = new EfUnitOfWork(context))
         {
             var           customer      = unitOfWork.GetRepository <Customer>().GetById(id);
             CustomerModel customerModel = new CustomerModel
             {
                 City         = customer.City,
                 CompanyName  = customer.CompanyName,
                 Address      = customer.Address,
                 Region       = customer.Region,
                 Phone        = customer.Phone,
                 ContactTitle = customer.ContactTitle,
                 ContactName  = customer.ContactName,
                 PostalCode   = customer.PostalCode,
                 Country      = customer.Country,
                 Fax          = customer.Fax,
             };
             return(customerModel);
         }
 }
Exemplo n.º 23
0
 public bool Delete(Guid id)
 {
     try
     {
         using (StockDbContext context = new StockDbContext())
             using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
             {
                 unitofwork.GetRepository <Customer>().Delete(id);
                 int savecount = unitofwork.SaveChanges();
                 if (savecount == 0)
                 {
                     return(false);
                 }
                 return(true);
             }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         throw;
     }
 }
Exemplo n.º 24
0
 public bool Update(ProductModel entity)
 {
     try
     {
         using (StockDbContext context = new StockDbContext())
             using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
             {
                 Product product = StockMapper.ProductMap(entity);
                 unitofwork.GetRepository <Product>().Update(product);
                 int saveCount = unitofwork.SaveChanges();
                 if (saveCount == 0)
                 {
                     return(false);
                 }
                 return(true);
             }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         throw;
     }
 }
Exemplo n.º 25
0
 public bool Delete(CategoryModel entity)
 {
     try
     {
         using (StockDbContext context = new StockDbContext())
             using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
             {
                 Category category = StockMapper.CategoryMap(entity);
                 unitofwork.GetRepository <Category>().Delete(category);
                 int saveCount = unitofwork.SaveChanges();
                 if (saveCount == 0)
                 {
                     return(false);
                 }
                 return(true);
             }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         throw;
     }
 }
Exemplo n.º 26
0
 public void TestMethodAdd()
 {
     using (StockDbContext context = new StockDbContext())
         using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
         {
             Customer customer = new Customer
             {
                 CustomerId   = Guid.NewGuid(),
                 City         = "ankara",
                 CompanyName  = "Tc",
                 Address      = "Yenımahalle",
                 Region       = "Tr",
                 Phone        = "5555555",
                 ContactTitle = "Onuur",
                 ContactName  = "Onur",
                 PostalCode   = "000",
                 Country      = "Turkiye",
                 Fax          = "00000",
             };
             unitofwork.GetRepository <Customer>().Add(customer);
             int saveCount = unitofwork.SaveChanges();
         }
 }
Exemplo n.º 27
0
 public void TestMethodUpdate()
 {
     using (StockDbContext context = new StockDbContext())
         using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
         {
             Customer customer = new Customer
             {
                 CustomerId   = new Guid("6CA80A72-F581-4E95-98AB-20DA9E310808"),
                 City         = "Niğde",
                 CompanyName  = "Çiftliği",
                 Address      = "Yenımahalle",
                 Region       = "Tr",
                 Phone        = "5555555",
                 ContactTitle = "Ali",
                 ContactName  = "Babanın",
                 PostalCode   = "000",
                 Country      = "Turkiye",
                 Fax          = "00000",
             };
             Guid Id = new Guid("6CA80A72-F581-4E95-98AB-20DA9E310808");
             unitofwork.GetRepository <Customer>().Update(customer);
             unitofwork.SaveChanges();
         }
 }
Exemplo n.º 28
0
 public void TestMethodDelete()
 {
     using (StockDbContext context = new StockDbContext())
         using (IUnitOfWork unitofwork = new EfUnitOfWork(context))
         {
             Customer customer = new Customer
             {
                 CustomerId   = new Guid("1B67D5CA-CFFD-447C-84BA-49651E9CE601"),
                 City         = "ankara",
                 CompanyName  = "Tc",
                 Address      = "Yenımahalle",
                 Region       = "Tr",
                 Phone        = "5555555",
                 ContactTitle = "Onuur",
                 ContactName  = "Onur",
                 PostalCode   = "000",
                 Country      = "Turkiye",
                 Fax          = "00000",
             };
             Guid Id = new Guid("1B67D5CA-CFFD-447C-84BA-49651E9CE601");
             unitofwork.GetRepository <Customer>().Delete(Id);
             unitofwork.SaveChanges();
         }
 }
Exemplo n.º 29
0
        public List <ProductModel> GetAlls()
        {
            using (StockDbContext context = new StockDbContext())
                using (IUnitOfWork unitOfWork = new EfUnitOfWork(context))
                {
                    var product = unitOfWork.GetRepository <Product>().GetAll();

                    List <ProductModel> productModels = product.Select(s => new ProductModel
                    {
                        ProductId       = s.ProductId,
                        Discontinued    = s.Discontinued,
                        CategoryId      = s.CategoryId,
                        SupplierId      = s.SupplierId,
                        ProductName     = s.ProductName,
                        UnitsInStock    = s.UnitsInStock,
                        UnitPrice       = s.UnitPrice,
                        QuantityPerUnit = s.QuantityPerUnit,
                        ReorderLevel    = s.ReorderLevel,
                        UnitsOnOrder    = s.UnitsOnOrder
                    }).ToList();

                    return(productModels);
                }
        }
Exemplo n.º 30
0
        public List <CustomerModel> GetAlls()
        {
            using (StockDbContext context = new StockDbContext())
                using (IUnitOfWork unitOfWork = new EfUnitOfWork(context))
                {
                    var customer = unitOfWork.GetRepository <Customer>().GetAll();

                    List <CustomerModel> customerModels = customer.Select(s => new CustomerModel
                    {
                        Address      = s.Address,
                        Region       = s.Region,
                        CompanyName  = s.CompanyName,
                        City         = s.City,
                        Phone        = s.Phone,
                        ContactName  = s.ContactName,
                        PostalCode   = s.PostalCode,
                        Country      = s.Country,
                        ContactTitle = s.ContactTitle,
                        Fax          = s.Fax
                    }).ToList();

                    return(customerModels);
                }
        }