Exemple #1
0
        public static ModelView.UserView getUserId(int Id)
        {
            db = new ShopOnlineEntities();
            WebUser user1 = db.WebUsers.Find(Id) as WebUser;

            ModelView.UserView uv = new ModelView.UserView();
            try
            {
                uv.id       = user1.ID;
                uv.name     = user1.name;
                uv.uAddress = user1.uAddress;
                uv.email    = user1.email;
                uv.pwd      = user1.pwd;
                uv.repwd    = user1.pwd;
                uv.phone    = user1.phone;
                uv.zipcode  = user1.zipcode;
                uv.username = user1.username;
                uv.avatar   = user1.avatar;
                return(uv);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(uv);
        }
Exemple #2
0
 public static bool addUser(ModelView.UserView item)
 {
     db = new ShopOnlineEntities();
     try
     {
         WebUser user = new WebUser
         {
             username = item.username,
             email    = item.email,
             //Mã hóa
             pwd      = Encrypt(item.pwd),
             name     = item.name,
             uAddress = item.uAddress,
             phone    = item.phone,
             zipcode  = item.zipcode
         };
         db.WebUsers.Add(user);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(false);
 }
Exemple #3
0
        public static bool updateInfo(ModelView.UserView item)
        {
            db = new ShopOnlineEntities();

            try
            {
                WebUser user1 = db.WebUsers.Find(item.id) as WebUser;
                user1.name     = item.name;
                user1.uAddress = item.uAddress;
                user1.pwd      = item.pwd;
                user1.phone    = item.phone;
                user1.zipcode  = item.zipcode;
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
Exemple #4
0
        public static ModelView.UserView loginUser(ModelView.UserView item)
        {
            db = new ShopOnlineEntities();
            try
            {
                WebUser user = db.WebUsers.Where(x => x.email == item.email).FirstOrDefault() as WebUser;
                if (user.ID > 0)
                {
                    item.pwd      = Decrypt(user.pwd);
                    item.id       = user.ID;
                    item.userType = user.usertype;
                    item.name     = user.name;
                    return(item);
                }
            }
            catch (Exception ex)
            {
                return(item);

                throw ex;
            }
            return(item);
        }