// get images by product id public static IEnumerable <Image> List(int?id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <Image>("SELECT * FROM Images WHERE ProductId = @0", id)); } }
// edit image public static void Edit(Image image) { using (var db = new ElectronicStoreConnectionDB()) { db.Update(image); } }
// add new image public static void Add(Image image) { using (var db = new ElectronicStoreConnectionDB()) { db.Insert(image); } }
// find image public static Image Find(int id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.SingleOrDefault <Image>("SELECT * FROM Images WHERE Id = @0", id)); } }
public static IEnumerable <Order> List() { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <Order>("SELECT * FROM Orders ORDER BY OrderDate DESC")); } }
public static void Add(View_Profile entity) { using (var db = new ElectronicStoreConnectionDB()) { db.Insert(entity); } }
public static IEnumerable <Comment> ProductComments(int id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <Comment>("SELECT * FROM Comments WHERE Status = 1 AND ProductId = @0 ORDER BY DateCreated DESC", id)); } }
public static AspNetUser Find(string id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.SingleOrDefault <AspNetUser>("SELECT * FROM AspNetUsers WHERE Id = @0", id)); } }
public static IEnumerable <Order> OrderPurchase(string id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <Order>("SELECT * FROM Orders WHERE UserId = @0 ORDER By OrderDate DESC", id)); } }
public static View_Profile Details(string id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.SingleOrDefault <View_Profile>("SELECT * FROM View_Profile WHERE Id = @0", id)); } }
public static IEnumerable <View_PurchaseHistory> PurchaseHistory(string id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <View_PurchaseHistory>("SELECT DISTINCT * FROM View_PurchaseHistory WHERE Id = @0", id)); } }
public static int Edit(Category entity) { using (var db = new ElectronicStoreConnectionDB()) { return(db.Update(entity)); } }
public static void Add(Category entity) { using (var db = new ElectronicStoreConnectionDB()) { db.Insert(entity); } }
public static void Add(OrderDetail entity) { using (var db = new ElectronicStoreConnectionDB()) { db.Insert(entity); } }
public static AspNetUserRole UserRoleDetails(string id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.SingleOrDefault <AspNetUserRole>("SELECT * FROM AspNetUserRoles WHERE UserId = @0", id)); } }
public static IEnumerable <View_OrderDetail> Details(int id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <View_OrderDetail>("SELECT * FROM View_OrderDetails WHERE Id = @0", id)); } }
// get top 10 best selling products public static IEnumerable <Product> Top10Featured() { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <Product>("SELECT TOP 10 * FROM Products WHERE Sold > 0 ORDER BY Sold DESC")); } }
public static void Insert(Comment entity) { using (var db = new ElectronicStoreConnectionDB()) { db.Insert(entity); } }
// delete a product public static int Delete(int id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.Delete <Product>("WHERE Id = @0", id)); } }
// get products list public static IEnumerable <Product> List() { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <Product>("SELECT * FROM Products ORDER BY DateModified DESC, DateCreated DESC")); } }
// add new product public static void Add(Product p) { using (var db = new ElectronicStoreConnectionDB()) { db.Insert(p); } }
public static View_Product ViewProduct(int id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.SingleOrDefault <View_Product>("SELECT * FROM View_Product WHERE Id = @0", id)); } }
public static IEnumerable <Brand> List() { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <Brand>("SELECT * FROM Brands WHERE Status = 1 ORDER BY Name")); } }
// get product by id public static Product Find(int?id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.SingleOrDefault <Product>("SELECT * FROM Products WHERE Id = @0", id)); } }
public static IEnumerable <View_ThreeMonthsStatistic> ThreeMonthsStatistics() { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <View_ThreeMonthsStatistic>("SELECT * FROM View_ThreeMonthsStatistics")); } }
public static int RoleEdit(AspNetUserRole entity) { using (var db = new ElectronicStoreConnectionDB()) { return(db.Update(entity)); } }
public static Category Details(int id) { using (var db = new ElectronicStoreConnectionDB()) { return(db.SingleOrDefault <Category>("WHERE Id = @0", id)); } }
public static IEnumerable <View_Profile> List() { using (var db = new ElectronicStoreConnectionDB()) { return(db.Query <View_Profile>("SELECT * FROM View_Profile ORDER BY Email, FirstName, LastName")); } }
public static int Insert(Order o) { using (var db = new ElectronicStoreConnectionDB()) { db.Insert(o); return(o.Id); } }
public static int Delete(string id) { using (var db = new ElectronicStoreConnectionDB()) { var user = Details(id); return(db.Delete(user)); } }