Ejemplo n.º 1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            WWUserService.UserServiceClient client = new WWUserService.UserServiceClient();
            model.password = EncodePassword(model.password);
            if (ModelState.IsValid)
            {
                WWUserService.ResponseModel response = client.login(model.username, model.password, 18);
                if (response.status)
                {
                    FormsAuthentication.SetAuthCookie(model.username, false);

                    UserModel user = new UserModel().clone(response.result);
                    Session["user"]       = user;
                    Session["tokenLogin"] = response.message;

                    client.Close();

                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    model.errorMessage = response.message;
                }

                client.Close();
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return(View(model));
        }
Ejemplo n.º 2
0
        /*
         * Constructor
         * get user model object if id defined
         */
        public UserModel(int id /* user id */, string token, int curLoginId)
        {
            WWUserService.UserServiceClient client = new WWUserService.UserServiceClient();

            WWUserService.ResponseModel response = client.getUser(token, curLoginId, id);

            if (response.status)
            {
                this.clone(response.result);
            }

            client.Close();
        }
Ejemplo n.º 3
0
        /*
         * findSuperintendent
         * find superintendent of supervisor,
         * if superintendent then return him/herself
         * return: UserModel (user of superintendent)
         */
        public UserModel findSuperintendent(string token, int curLoginId)
        {
            // code here
            WWUserService.UserServiceClient client = new WWUserService.UserServiceClient();

            WWUserService.ResponseModel response = client.getSuperintendent(token, curLoginId, this.id);
            UserModel user = new UserModel();

            if (response.status)
            {
                user.clone(response.result);
            }

            client.Close();
            return(user);
        }
Ejemplo n.º 4
0
        public List <UserModel> getAllEmployee(string token, int curLoginId)
        {
            WWUserService.UserServiceClient client = new WWUserService.UserServiceClient();
            int count = 0;
            List <UserModel> listUser = new List <UserModel>();

            WWUserService.ResponseModel response = client.listUser(token, curLoginId, 50, 250);

            while (response.status && count < response.results.count)
            {
                foreach (WWUserService.UserModel us in response.results.listUserModel)
                {
                    listUser.Add(new UserModel().clone(us));
                }

                response = client.listUser(token, curLoginId, 50, count);
                count   += 50;
            }

            client.Close();

            return(listUser.OrderBy(p => p.alpha_name).ToList());
        }