public async Task<ActionResult> UserList()
        {
            try
            {
                // Get query IEnumerable ParseUser
                var users = await ParseUser.Query.WhereEqualTo("type", 1).FindAsync();

                List<UserViewModel> userModels = new List<UserViewModel>();

                foreach (ParseUser p in users)
                {
                    UserViewModel user = new UserViewModel();
                    user.userId = p.ObjectId;
                    user.username = p.Get<string>("username");
                    user.firstName = p.Get<string>("firstName");
                    user.lastName = p.Get<string>("lastName");
                    user.phoneNumber = p.Get<string>("phoneNumber");
                    user.address = p.Get<string>("address");
                    user.birthday = p.Get<DateTime>("birthday");
                    user.email = p.Get<string>("email");
                    user.isMale = p.Get<bool>("gender");
                    user.role = p.Get<string>("role");

                    // Add user model into list 
                    userModels.Add(user);
                }

                return View(userModels);
            }
            catch (ParseException pe)
            {
                ViewBag.Error = pe.Message;
                return RedirectToAction("Error");
            }
        }
        public async Task<ActionResult> CustomerList()
        {
            try {
                // Get query IEnumerable ParseUser
                var customers = await ParseUser.Query.WhereEqualTo("type", 0).FindAsync();

                List<UserViewModel> customerModels = new List<UserViewModel>();

                foreach (ParseUser p in customers)
                {
                    UserViewModel customer = new UserViewModel();
                    customer.userId = p.ObjectId;
                    customer.username = p.Get<string>("username");
                    customer.firstName = p.Get<string>("firstName");
                    customer.lastName = p.Get<string>("lastName");
                    customer.phoneNumber = p.Get<string>("phoneNumber");
                    customer.address = p.Get<string>("address");
                    customer.birthday = p.Get<DateTime>("birthday");
                    customer.email = p.Get<string>("email");
                    customer.gender = p.Get<string>("gender");
                    customer.role = p.Get<string>("role");

                    // Add user model into list 
                    customerModels.Add(customer);
                }

                return View(customerModels);
            }
            catch (ParseException)
            {
                return View();
            }
        }
Exemple #3
0
        public async Task<ActionResult> Profiles()
        {
            if (Session["login"] != null && ParseUser.CurrentUser != null)
            {
                UserViewModel currentUser = new UserViewModel();
                var user = await ParseUser.Query.WhereEqualTo("type", 1).GetAsync(ParseUser.CurrentUser.ObjectId);

                currentUser.userId = user.ObjectId;
                currentUser.username = user.Get<string>("username");
                currentUser.firstName = user.Get<string>("firstName");
                currentUser.lastName = user.Get<string>("lastName");
                currentUser.phoneNumber = user.Get<string>("phoneNumber");
                currentUser.address = user.Get<string>("address");
                currentUser.birthday = user.Get<DateTime>("birthday");
                currentUser.email = user.Get<string>("email");
                currentUser.gender = user.Get<string>("gender");
                currentUser.role = user.Get<string>("role");

                return View(currentUser);
            }
            else
            {
                return RedirectToAction("Login");
            }

        }
Exemple #4
0
 public ActionResult Register(UserViewModel user)
 {
     return View();
 }
        public async Task<ActionResult> EditUser(string id)
        {
            try
            {
                var user = await ParseUser.Query.WhereEqualTo("type", 1).GetAsync(id);
                UserViewModel _user = new UserViewModel();

                _user.userId = user.ObjectId;
                _user.username = user.Get<string>("username");
                _user.firstName = user.Get<string>("firstName");
                _user.lastName = user.Get<string>("lastName");
                _user.phoneNumber = user.Get<string>("phoneNumber");
                _user.address = user.Get<string>("address");
                _user.birthday = user.Get<DateTime>("birthday");
                _user.email = user.Get<string>("email");
                _user.isMale = user.Get<bool>("gender");
                _user.role = user.Get<string>("role");

                return View(_user);
            }
            catch (ParseException pe)
            {
                ViewBag.Error = "Error getting user " + pe.Message;
                return View();
            }
        }