public void Insert(Customer customer) { using (var entities = new toysforboysEntities()) { if (customer.email != null) { var query = from c in entities.customers where c.email == customer.email select c; if (query.Count() == 0) { entities.customers.Add(customer); entities.SaveChanges(); } else { throw new Exception("Email already in use"); } } else { entities.customers.Add(customer); entities.SaveChanges(); } } }
public IEnumerable <Orderdetail> GetOrderDetails(Order order) { var orderdetails = new List <Orderdetail>(); using (var entities = new toysforboysEntities()) { foreach (var od in entities.orderdetails) { if (order.id == od.orderId) { orderdetails.Add(od); } } } //using (var entities = new toysforboysEntities()) //{ // var query = (from orderdetail in entities.orderdetails // where orderdetail.orderId == order.id // orderby orderdetail.productId // select orderdetail).Include("product"); // return query; //} return(orderdetails); }
public void AddEmailAndPassword(string name, string email, string password) { using (var entities = new toysforboysEntities()) { var query = (from customer in entities.customers where customer.name == name select customer).First(); var query2 = from customer in entities.customers where customer.email == email select customer; if (query != null && query2.Count() == 0) { query.email = email; query.password = password; entities.SaveChanges(); } else { if (query == null) { throw new Exception("Customer's name not found"); } if (query2.Count() > 0) { throw new Exception("Email is already in use"); } } } }
public void Insert(Admin admin) { using (var entities = new toysforboysEntities()) { if (admin.username != null && admin.password != null) { var query = from a in entities.admins where a.username == admin.username select a; if (query.Count() == 0) { entities.admins.Add(admin); entities.SaveChanges(); } else { throw new Exception("Username already in use"); } } else { if (admin.username == null) { throw new Exception("No username given"); } if (admin.password == null) { throw new Exception("No password given"); } } } }
public void Insert(Product product) { using (var entities = new toysforboysEntities()) { entities.products.Add(product); entities.SaveChanges(); } }
public void Delete(Admin admin) { using (var entities = new toysforboysEntities()) { entities.admins.Remove(admin); entities.SaveChanges(); } }
public void Insert(Country country) { using (var entities = new toysforboysEntities()) { entities.countries.Add(country); entities.SaveChanges(); } }
public void Insert(Orderdetail orderdetail) { using (var entities = new toysforboysEntities()) { entities.orderdetails.Add(orderdetail); entities.SaveChanges(); } }
public void Delete(Product product) { using (var entities = new toysforboysEntities()) { entities.products.Attach(product); entities.products.Remove(product); entities.SaveChanges(); } }
public void Delete(Customer customer) { using (var entities = new toysforboysEntities()) { entities.customers.Attach(customer); entities.customers.Remove(customer); entities.SaveChanges(); } }
public void Delete(Country country) { using (var entities = new toysforboysEntities()) { entities.countries.Attach(country); entities.countries.Remove(country); entities.SaveChanges(); } }
public void Delete(Orderdetail orderdetail) { using (var entities = new toysforboysEntities()) { entities.orderdetails.Attach(orderdetail); entities.orderdetails.Remove(orderdetail); entities.SaveChanges(); } }
public Admin LoginVerification(string username, string password) { using (var entities = new toysforboysEntities()) { var query = (from admin in entities.admins where admin.username == username && admin.password == password select admin).FirstOrDefault(); return(query); } }
public Customer LoginVerification(string email, string password) { using (var entities = new toysforboysEntities()) { var query = (from customer in entities.customers where customer.email == email && customer.password == password select customer).FirstOrDefault(); return(query); } }
public Country GetById(int countryID, string includes) { using (var entities = new toysforboysEntities()) { var query = (from country in entities.countries where country.id == countryID orderby country.id select country).Include(includes).First(); return(query); } }
public Customer GetById(int customerID, string includes) { using (var entities = new toysforboysEntities()) { var query = (from customer in entities.customers where customer.id == customerID orderby customer.id select customer).Include(includes).First(); return(query); } }
public Product GetById(int productID) { using (var entities = new toysforboysEntities()) { var query = (from product in entities.products where product.id == productID orderby product.id select product).First(); return(query); } }
public Admin GetById(int adminId, string includes) { using (var entities = new toysforboysEntities()) { var query = (from admin in entities.admins where admin.id == adminId orderby admin.id select admin).Include(includes).First(); return(query); } }
public Productline GetById(int productlineID, string includes) { using (var entities = new toysforboysEntities()) { var query = (from productline in entities.productlines where productline.id == productlineID orderby productline.id select productline).Include(includes).First(); return(query); } }
public Orderdetail GetById(int orderdetailID, int productID) { using (var entities = new toysforboysEntities()) { var query = (from orderdetail in entities.orderdetails where orderdetail.orderId == orderdetailID && orderdetail.productId == productID orderby orderdetail.orderId select orderdetail).First(); return(query); } }
public Order GetById(int orderID, string includes) { using (var entities = new toysforboysEntities()) { var query = (from order in entities.orders where order.id == orderID orderby order.id select order).Include(includes).First(); return(query); } }
public IEnumerable <Country> GetAll() { List <Country> AllCountries = new List <Country>(); using (var entities = new toysforboysEntities()) { foreach (var country in entities.countries) { AllCountries.Add(country); } } return(AllCountries); }
public void Edit(Country country) { using (var entities = new toysforboysEntities()) { var originalCountry = entities.countries.Find(country.id); if (country.name != string.Empty) { originalCountry.name = country.name; } entities.SaveChanges(); } }
public IEnumerable <Country> GetAll(Func <Country, bool> predicate, string includes) { List <Country> AllCountries = new List <Country>(); using (var entities = new toysforboysEntities()) { foreach (var country in (String.IsNullOrEmpty(includes) ? entities.countries : entities.countries.Include(includes)).Where(predicate)) { AllCountries.Add((Country)country); } } return(AllCountries); }
public IEnumerable <Product> GetAll() { List <Product> AllProducts = new List <Product>(); using (var entities = new toysforboysEntities()) { foreach (var product in entities.products) { AllProducts.Add(product); } } return(AllProducts); }
public IEnumerable <Admin> GetAll() { List <Admin> AllAdmins = new List <Admin>(); using (var entities = new toysforboysEntities()) { foreach (var admin in entities.admins) { AllAdmins.Add(admin); } } return(AllAdmins); }
public IEnumerable <Admin> GetAll(Func <Admin, bool> predicate, string includes) { List <Admin> AllAdmins = new List <Admin>(); using (var entities = new toysforboysEntities()) { foreach (var admin in (String.IsNullOrEmpty(includes) ? entities.admins : entities.admins.Include(includes)).Where(predicate)) { AllAdmins.Add((Admin)admin); } } return(AllAdmins); }
public IEnumerable <Product> GetAll(Func <Product, bool> predicate, string includes) { List <Product> AllProducts = new List <Product>(); using (var entities = new toysforboysEntities()) { foreach (var Product in (String.IsNullOrEmpty(includes) ? entities.products : entities.products.Include(includes)).Where(predicate)) { AllProducts.Add((Product)Product); } } return(AllProducts); }
public IEnumerable <Orderdetail> GetAll() { List <Orderdetail> AllOrderdetails = new List <Orderdetail>(); using (var entities = new toysforboysEntities()) { foreach (var orderdetail in entities.orderdetails) { AllOrderdetails.Add(orderdetail); } } return(AllOrderdetails); }
public IEnumerable <Order> GetAll(Func <Order, bool> predicate, string includes) { List <Order> Allorders = new List <Order>(); using (var entities = new toysforboysEntities()) { foreach (var order in (String.IsNullOrEmpty(includes) ? entities.orders : entities.orders.Include(includes)).Where(predicate)) { Allorders.Add((Order)order); } } return(Allorders); }