public IHttpActionResult Get(long userId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Admin admin = adminLogic.GetUserAdmin(userId);

            if (admin == null)
            {
                return(NotFound());
            }
            return(Ok(admin));
        }
예제 #2
0
        private void buttonSignIn_Click(object sender, EventArgs e)
        {
            string email    = textBoxEmail.Text;
            string password = textBoxPassword.Text;
            User   user     = new User();

            user.Email    = email;
            user.Password = password;
            User searchedUser = null;
            bool badPassword  = false;

            try
            {
                searchedUser = userLogic.LogIn(user);
            }
            catch (UserException ex)
            {
                badPassword = true;
                MessageBox.Show(ex.Message);
            }
            if (searchedUser != null && searchedUser.IsAdmin)
            {
                actualAdmin          = adminLogic.GetUserAdmin(searchedUser.Id);
                panelSignIn.Visible  = false;
                panelOptions.Visible = true;
            }
            else
            {
                if (searchedUser == null && !badPassword)
                {
                    MessageBox.Show("El usuario no existe", "Error");
                }
                else if (searchedUser != null && !searchedUser.IsAdmin && !badPassword)
                {
                    MessageBox.Show("El usuario no es de tipo administrador", "Error");
                }
            }
        }