예제 #1
0
 public static Admin Get(Admin admin)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Admin.FirstOrDefault(a => a.UserName == admin.UserName && a.Password == admin.Password));
     }
 }
예제 #2
0
 public static Customer Get(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Customer.Find(id));
     }
 }
예제 #3
0
 public static List <Category> GetAllForHome()
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Category.ToList());
     }
 }
예제 #4
0
 public static string GetWriterName(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Writer.Find(id).WriterName);
     }
 }
예제 #5
0
 public static string GetCategoryName(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Category.Find(id).CategoryName);
     }
 }
예제 #6
0
 public static void AddCustomer(Customer customer)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         db.Customer.Add(customer);
         db.SaveChanges();
     }
 }
 public ProductsController(ProductModel model, RepProducts rep, ETicaretContext db, RepGallery repglr, RepCategories repCat)
 {
     _rep    = rep;
     _model  = model;
     _db     = db;
     _repglr = repglr;
     _repcat = repCat;
 }
예제 #8
0
 public static void Add(Custom custom)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         db.Custom.Add(custom);
         db.SaveChanges();
     }
 }
예제 #9
0
        static void Main(string[] args)
        {
            using (ETicaretContext db = new ETicaretContext())
            {
                Admin a = new Admin();
                a.UserName = "******";
                a.Password = "******";

                db.Admin.Add(a);

                Category c = new Category();
                c.CategoryName = "Tarih";
                db.Category.Add(c);



                Writer w = new Writer();
                w.WriterName = "Hakan";
                db.Writer.Add(w);


                Book b = new Book()
                {
                    BookName     = "bookname",
                    BookSubject  = "subject",
                    CategoryID   = 1,
                    Price        = 10,
                    WriterID     = 1,
                    PageCount    = 100,
                    BookPhotoURL = "http://placehold.it/800x300",
                };

                db.Book.Add(b);


                Customer cu = new Customer()
                {
                    NameSurname = "Hakan Karanfil",
                    Address     = "izmir",
                    Total       = 30,
                };

                db.Customer.Add(cu);

                Product s = new Product()
                {
                    BookID       = 1,
                    BookCount    = 1,
                    BookPhotoURL = "http://placehold.it/800x300",
                    BookName     = "Bookname",
                    Price        = 20,
                };

                db.Product.Add(s);

                db.SaveChanges();
            }
        }
 public GalleryController(RepProducts reppro, RepGallery rep, ETicaretContext db, ProductModel model, RepCategories repcat, GalleryModel modelglr)
 {
     _rep      = rep;
     _db       = db;
     _model    = model;
     _repcat   = repcat;
     _reppro   = reppro;
     _modelglr = modelglr;
 }
예제 #11
0
 public static Customer CheckCustomer(Customer customer)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Customer
                .Include("CustomList")
                .Where(c => c.Email.Equals(customer.Email) && c.Password.Equals(customer.Password))
                .FirstOrDefault());
     }
 }
예제 #12
0
 public static List <Custom> GetOrders(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Customer
                .Include("CustomList")
                .FirstOrDefault(c => c.CustomerID == id)
                .CustomList.OrderByDescending(c => c.OrderDate)
                .ToList());
     }
 }
        public UrunIslemleri(ETicaretContext context, IWebHostEnvironment hostEnvironment)
        {
            _context         = context;
            _hostEnvironment = hostEnvironment;

            _dosyaYolu = Path.Combine(_hostEnvironment.WebRootPath, "resimler");
            if (!Directory.Exists(_dosyaYolu))
            {
                Directory.CreateDirectory(_dosyaYolu);
            }
        }
예제 #14
0
        public static Customer UpdateCustomerPassword(Customer customer, string newPassword)
        {
            using (ETicaretContext db = new ETicaretContext())
            {
                var toBeUpdated = db.Customer.Find(customer.CustomerID);
                toBeUpdated.Password = newPassword;

                db.SaveChanges();

                return(toBeUpdated);
            }
        }
예제 #15
0
        public static Customer UpdateCustomerAddress(Customer customer)
        {
            using (ETicaretContext db = new ETicaretContext())
            {
                var toBeUpdated = db.Customer.Find(customer.CustomerID);

                toBeUpdated.Address = customer.Address;

                db.SaveChanges();

                return(toBeUpdated);
            }
        }
예제 #16
0
 public static ViewBookForHome GetBookForShop(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Book.Where(b => b.BookID == id)
                .Select(b => new ViewBookForHome
         {
             BookID = b.BookID,
             WriterID = b.WriterID,
             BookName = b.BookName,
             WriterName = b.Writer.WriterName,
             Price = b.Price,
             BookPhotoURL = b.BookPhotoURL
         }).FirstOrDefault());
     }
 }
예제 #17
0
 public static List <ViewBookForHome> GetAllForWriter(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Book.Where(w => w.WriterID == id)
                .Select(b => new ViewBookForHome
         {
             BookID = b.BookID,
             WriterID = b.WriterID,
             BookName = b.BookName,
             WriterName = b.Writer.WriterName,
             Price = b.Price,
             BookPhotoURL = b.BookPhotoURL
         }).ToList());
     }
 }
예제 #18
0
 public static List <ViewBookForCategory> GetAllBook(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Book.Where(b => b.CategoryID == id)
                .Select(b => new ViewBookForCategory
         {
             BookID = b.BookID,
             WriterID = b.WriterID,
             BookName = b.BookName,
             WriterName = b.Writer.WriterName,
             Price = b.Price,
             BookPhotoURL = b.BookPhotoURL,
             CategoryID = b.CategoryID,
         }).ToList());
     }
 }
예제 #19
0
 public static ViewBookForDetails Get(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Book.Where(b => b.BookID == id)
                .Select(b => new ViewBookForDetails
         {
             BookID = b.BookID,
             WriterID = b.WriterID,
             BookName = b.BookName,
             WriterName = b.Writer.WriterName,
             Price = b.Price,
             BookSubject = b.BookSubject,
             PageCount = b.PageCount,
             BookPhotoURL = b.BookPhotoURL
         }).FirstOrDefault());
     }
 }
예제 #20
0
        public static string AddCustomer(Customer customer)
        {
            using (ETicaretContext db = new ETicaretContext())
            {
                var isThereCustomer = db.Customer.SingleOrDefault(c => c.Email == customer.Email);

                if (isThereCustomer != null)
                {
                    return("Girdiğiniz e-posta adresi zaten kullanılıyor.");
                }
                else
                {
                    db.Customer.Add(customer);
                    db.SaveChanges();
                    return("Success");
                }
            }
        }
예제 #21
0
 public static List <ViewForHome> GetAllBooksByWriter(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Book
                .Where(b => b.WriterID == id)
                .Select(b => new ViewForHome
         {
             BookID = b.BookID,
             BookName = b.BookName,
             PhotoUrl = b.PhotoUrl,
             Publisher = b.Publisher,
             Price = b.Price,
             WriterID = b.WriterID,
             WriterName = b.Writer.WriterName,
         }).ToList());
     }
 }
예제 #22
0
 public static List <ViewForHome> Search(string search)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Book.Select(b => new ViewForHome
         {
             BookID = b.BookID,
             BookName = b.BookName,
             Price = b.Price,
             PhotoUrl = b.PhotoUrl,
             Publisher = b.Publisher,
             WriterID = b.WriterID,
             WriterName = b.Writer.WriterName,
             CategoryID = b.CategoryID,
             CategoryName = b.Category.CategoryName,
         })
                .Where(b => b.BookName.Contains(search) || b.CategoryName.Contains(search) || b.WriterName.Contains(search))
                .ToList());
     }
 }
예제 #23
0
 public static List <ViewForHome> GetAllForHome()
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Book.Select(b => new ViewForHome
         {
             BookID = b.BookID,
             BookName = b.BookName,
             Price = b.Price,
             PhotoUrl = b.PhotoUrl,
             Publisher = b.Publisher,
             WriterID = b.WriterID,
             WriterName = b.Writer.WriterName,
             CategoryID = b.CategoryID,
             CategoryName = b.Category.CategoryName,
         })
                .OrderByDescending(b => b.BookID)
                .ToList());
     }
 }
예제 #24
0
        public static List <ViewBookForHome> SearchAll(string search)
        {
            using (ETicaretContext db = new ETicaretContext())
            {
                return(db.Book.
                       Select(b => new ViewBookForHome
                {
                    BookID = b.BookID,
                    WriterID = b.WriterID,
                    BookName = b.BookName,
                    WriterName = b.Writer.WriterName,
                    Price = b.Price,
                    BookPhotoURL = b.BookPhotoURL
                }).Where(n => n.BookName.Contains(search)).ToList());
                //name.Where(m => m.BookName.Contains(search));

                //var name = db.Book.Where(n => n.BookName.Contains(search));
                //return name.ToList();
            }
        }
예제 #25
0
 public static ViewBookForDetails GetForDetails(int id)
 {
     using (ETicaretContext db = new ETicaretContext())
     {
         return(db.Book
                .Where(b => b.BookID == id)
                .Select(b => new ViewBookForDetails
         {
             BookID = b.BookID,
             BookName = b.BookName,
             BookSubject = b.BookSubject,
             Publisher = b.Publisher,
             Price = b.Price,
             PhotoUrl = b.PhotoUrl,
             WriterID = b.WriterID,
             WriterName = b.Writer.WriterName,
             CategoryID = b.CategoryID,
             CategoryName = b.Category.CategoryName
         }).FirstOrDefault());
     }
 }
예제 #26
0
        public static void Seed()
        {
            var context = new ETicaretContext();

            //Bekleyen migration yoksa test belleğini databaseye yükle
            if (context.Database.GetPendingMigrations().Count() == 0)
            {
                //Database boşsa eklesin
                if (context.Categories.Count() == 0)
                {
                    context.Categories.AddRange(Categories);
                }

                if (context.Products.Count() == 0)
                {
                    context.Products.AddRange(Products);
                    context.AddRange(ProductCategory);
                }

                context.SaveChanges();
            }
        }
예제 #27
0
        public static ViewOrderDetails GetOrderDetails(int id)
        {
            using (ETicaretContext db = new ETicaretContext())
            {
                return db.Custom.Include("ShoppingBag")
                            .Where(c => c.CustomID == id)
                            .Select(c => new ViewOrderDetails
                            {
                                CustomID = id,
                                TotalBill = c.TotalBill,
                                OrderDate = c.OrderDate,
                                ShippingAddress = c.ShippingAddress,
                                ShoppingBag = c.ShoppingBag,

                                CustomerID = c.CustomerID,
                                Name = c.Customer.Name,
                                Surname = c.Customer.Surname,
                                Phone = c.Customer.Phone,

                            }).FirstOrDefault();

            }
        }
예제 #28
0
 public UserService(ETicaretContext context)
 {
     _context = context;
 }
 public ProductRepository(ETicaretContext context) : base(context)
 {
 }
예제 #30
0
 public BaseRepository(ETicaretContext db)
 {
     _db = db;
 }