Пример #1
0
        /// <summary>
        /// Called when the Update button is clicked by the user
        /// </summary>
        protected void saveUserDetailsButton_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString[Constants.ID]);
            var userData = new AppDataContract(id,
                                               SSN.Text,
                                               FirstName.Text,
                                               LastName.Text,
                                               Phone.Text.Replace("-", ""),
                                               DateTime.Today);
            var service = new OmicronService.OmicronServiceClient();

            bool userOkay = false;

            try
            {
                userOkay = service.ChangeUserData(userData, (Guid)Session[Constants.USER_TOKEN]);
            }
            catch
            {
                Response.Redirect(Constants.LOGIN_PAGE);
            }

            if (userOkay)
            {
                Response.Redirect(Constants.VIEW_PAGE_PARTIAL + id);
            }
            else
            {
                Response.Redirect(Constants.LOGIN_PAGE);
            }
        }
Пример #2
0
        /// <summary>
        /// Called when the page loads
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            // If we don't have a valid session, then get out of here
            if (!validSession())
            {
                return;
            }

            // Otherwise, open up a link to the web service
            var service = new OmicronService.OmicronServiceClient();

            // Get all the users
            var users = service.GetUserData(-1, (Guid)Session[Constants.USER_TOKEN]);

            // If this is null, then we aren't authorized to be here, so let's leave.
            if(users == null)
            {
                Response.Redirect(Constants.LOGIN_PAGE);
                return;
            }

            // Otherwise, fill up the table with the user's data.
            adminTableRow.DataSource = users;
            adminTableRow.DataBind();
        }
Пример #3
0
        /// <summary>
        /// Called when the login button is pressed
        /// </summary>
        protected void LoginData_Authenticate(object sender, AuthenticateEventArgs e)
        {
            // Open a connection to the service
            var service = new OmicronService.OmicronServiceClient();

            WebService.DataContracts.ValidUserContract user;

            // Get the user based of their credentials
            try
            {
                user = service.ValidUser(LoginData.UserName, LoginData.Password);
            }
            catch
            {
                return;
            }

            // If an invalid user, we're done here.
            if(user.UserType == UserType.INVALID)
            {
                return;
            }

            Session[Constants.USER_TOKEN] = user.GUID;
            Session[Constants.IS_ADMIN] = user.UserType == UserType.ADMIN;

            // If they're an admin, then go to the admin view
            if (user.UserType == UserType.ADMIN)
            {
                Response.Redirect(Constants.ADMIN_PAGE);
            }
            // Otherwise, if they're a user, go to the user view
            else if(user.UserType == UserType.USER)
            {
                Response.Redirect(Constants.VIEW_PAGE_PARTIAL + user.ID);
            }

            // Otherwise, they'll be given an invalid login.
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && validSession())
            {
                try
                {
                    int id = Convert.ToInt32(Request.QueryString[Constants.ID]);

                    var service = new OmicronService.OmicronServiceClient();
                    WebService.DataContracts.AppDataContract userData;

                    userData = service.GetUserData(id, (Guid)Session[Constants.USER_TOKEN])[0];
                    Title = (userData.FirstName + " " + userData.LastName + " Application");

                    // We should only get one.
                    placeUserData(userData);
                }
                catch
                {
                    Response.Redirect("/");
                }
            }
        }