public bool Check_username(string username) { Models.Entity.ChocoGearEntities db = new Entity.ChocoGearEntities(); var q = db.Customers.Where(d => d.username.Equals(username)).Count(); if (q > 0) { return(true); } return(false); }
public bool Check_email(string email) { Models.Entity.ChocoGearEntities db = new Entity.ChocoGearEntities(); var q = db.Customers.Where(d => d.email.Equals(email)).Count(); if (q > 0) { return(true); } return(false); }
public bool CheckPass(string password) { Models.Entity.ChocoGearEntities db = new Entity.ChocoGearEntities(); var q = db.Customers.Where(d => d.password.Equals(password)).Count(); if (q > 0) { return(true); } return(false); }
public CustomerView GetId(int id) { Models.Entity.ChocoGearEntities db = new Entity.ChocoGearEntities(); var q = db.Customers.Where(d => d.id == id).Select(d => new ModelView.CustomerView() { id = d.id, first_name = d.first_name, last_name = d.last_name, phone = d.phone, email = d.email, address = d.address, username = d.username, password = d.password, }).FirstOrDefault(); return(q); }
public ProductView GetId(int id) { Models.Entity.ChocoGearEntities db = new Entity.ChocoGearEntities(); var q = db.Products.Where(d => d.id == id).Select(d => new ModelView.ProductView() { id = d.id, name_product = d.name_product, name_image = d.name_image, created = (DateTime)d.created, price = (float)d.price, description = d.description, discount = (float)d.discount, name_category = d.Category.name_category, name_brand = d.Brand.name, status = (bool)d.status }).FirstOrDefault(); return(q); }
public int Update(CustomerView item) { try { Models.Entity.ChocoGearEntities db = new Entity.ChocoGearEntities(); var q = db.Customers.Where(d => d.id == item.id).FirstOrDefault(); q.id = item.id; q.first_name = item.first_name; q.last_name = item.last_name; q.phone = item.phone; q.email = item.email; q.address = item.address; q.password = item.password; db.SaveChanges(); return(1); } catch (Exception) { return(0); } }
public int Update(ProductView item) { try { Models.Entity.ChocoGearEntities db = new Entity.ChocoGearEntities(); var q = db.Products.Where(d => d.id == item.id).FirstOrDefault(); q.id = item.id; q.name_product = item.name_product; q.name_image = item.name_image; q.price = item.price; q.description = item.description; q.status = item.status; q.id_category = item.id_category; q.id_brand = item.id_brand; db.SaveChanges(); return(1); } catch (Exception) { return(0); } }