/// <summary> /// Adds member to the database /// </summary> /// <param name="m"></param> public static void RegisterMember(Member m) { ECommerceDB db = new ECommerceDB(); db.Members.Add(m); db.SaveChanges(); //MUST call SaveChanges for INSERTS, UPDATES, and DELETES! }
public static void UpdateProduct(Product p) { ECommerceDB db = new ECommerceDB(); db.Entry(p).State = EntityState.Modified; db.SaveChanges(); }
/// <summary> /// Adds product to database /// </summary> /// <param name="p"></param> public static void AddProduct(Product p) { var db = new ECommerceDB(); db.Products.Add(p); db.SaveChanges(); }
public static void DeleteProductById(int value) { ECommerceDB db = new ECommerceDB(); Product p = db.Products.Find(value); db.Products.Remove(p); db.SaveChanges(); }
public static List <Product> GetAllProducts() { ECommerceDB db = new ECommerceDB(); //List<Product> prods = db.Products.ToList(); List <Product> prods = (from p in db.Products select p).ToList(); return(prods); }
/// <summary> /// Finds a member with the supplied credentials /// Returns null if there is no match /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public static Member FindMember(string username, string password) { var db = new ECommerceDB(); //finds users with supplied credentials return((from mem in db.Members where mem.Username == username && mem.Password == password select mem).SingleOrDefault()); }
public static bool DoesUsernameExist(string username) { ECommerceDB db = new ECommerceDB(); int count = (from u in db.Members where u.Username == username select u).Count(); return((count == 1) ? true : false); }
public static Member GetCurrentMember() { int id = SessionHelper.GetCurrentUserId(); ECommerceDB db = new ECommerceDB(); Member mem = (from m in db.Members where m.MemberID == id select m).Single(); return(mem); }
internal static Product GetProductById(int id) { ECommerceDB db = new ECommerceDB(); //Product p = db.Products.Find(id); //return p; Product p = (from prod in db.Products where prod.ProductID == id select prod).SingleOrDefault(); return(p); }