Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 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);
     }
 }
Exemplo n.º 7
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);
     }
 }