public static Admin Get(Admin admin) { using (ETicaretContext db = new ETicaretContext()) { return(db.Admin.FirstOrDefault(a => a.UserName == admin.UserName && a.Password == admin.Password)); } }
public static Customer Get(int id) { using (ETicaretContext db = new ETicaretContext()) { return(db.Customer.Find(id)); } }
public static List <Category> GetAllForHome() { using (ETicaretContext db = new ETicaretContext()) { return(db.Category.ToList()); } }
public static string GetWriterName(int id) { using (ETicaretContext db = new ETicaretContext()) { return(db.Writer.Find(id).WriterName); } }
public static string GetCategoryName(int id) { using (ETicaretContext db = new ETicaretContext()) { return(db.Category.Find(id).CategoryName); } }
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; }
public static void Add(Custom custom) { using (ETicaretContext db = new ETicaretContext()) { db.Custom.Add(custom); db.SaveChanges(); } }
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; }
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()); } }
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); } }
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); } }
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); } }
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()); } }
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()); } }
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()); } }
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()); } }
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"); } } }
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()); } }
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()); } }
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()); } }
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(); } }
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()); } }
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(); } }
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(); } }
public UserService(ETicaretContext context) { _context = context; }
public ProductRepository(ETicaretContext context) : base(context) { }
public BaseRepository(ETicaretContext db) { _db = db; }