public async Task <IActionResult> PostBusinessLogin([FromBody] BusinessLogin businessLogin)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.BusinessLogin.Add(businessLogin);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (BusinessLoginExists(businessLogin.Id))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetBusinessLogin", new { id = businessLogin.Id }, businessLogin));
        }
        public async Task <IActionResult> PutBusinessLogin([FromRoute] int id, [FromBody] BusinessLogin businessLogin)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != businessLogin.Id)
            {
                return(BadRequest());
            }

            _context.Entry(businessLogin).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BusinessLoginExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        private void btAceptar_Click(object sender, EventArgs e)
        {
            string userName = this.txtUser.Text;
            string password = this.txtPass.Text;

            this.button3.Visible = true;
            this.button3.Enabled = false;
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Ninguno de los campos puede estar vacío");
            }
            else
            {
                BusinessLogin bLogin = new BusinessLogin(userName, password);
                bLogin.CreateFirstUser();
                bool isUserTrue = bLogin.CheckUser();
                if (isUserTrue)
                {
                    ControlPanel mPannel = new ControlPanel();
                    mPannel.UserName = userName;
                    mPannel.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Usuario Incorrecto, póngase en contacto con el administrador");
                    this.txtPass.Text    = string.Empty;
                    this.txtUser.Text    = string.Empty;
                    this.button3.Visible = false;
                    this.button3.Enabled = true;
                }
            }
        }
        public JsonResult Logar(LoginViewModel model)
        {
            var retorno = new BusinessLogin().Logar(model.Login);

            if (retorno.IsValido)
            {
                Session[UsuarioLogado.SESSION_USUARIO_LOGADO] = (retorno.Entity as Login);
            }

            return(Json(retorno, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            BusinessLogin login = new BusinessLogin();

            if (login.Login(tbUserID.Text, tbPassword.Text))
            {
                if (true)
                {
                }
            }
            else
            {
                MessageBox.Show("Login Failed!", "Waring!"
                                , MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 6
0
        public IActionResult Authenticate([FromBody] BusinessLogin userParam)
        {
            //var user = _userService.Authenticate(userParam.Email, userParam.Psswd);
            UserTempStorage.salt = userParam.Salt;

            bl = _userService.Authenticate(userParam.Email, userParam.Psswd, userParam.Salt);

            if (bl == null)
            {
                return(BadRequest(new { message = "Username or password is incorrect" }));
            }
            UserTempStorage.salt  = bl.Salt;
            UserTempStorage.email = bl.Email;

            return(Ok(bl));
        }
Exemplo n.º 7
0
        public IActionResult Logout([FromBody] BusinessLogin userParam)
        {
            string email = UserTempStorage.email;

            //set user token to nothing
            bl = _userService.Logout(email);
            //var user = _userService.Logout();

            UserTempStorage.email = "";

            return(Ok(bl));

            //if (user == null)
            //    return BadRequest(new { message = "Username or password is incorrect" });

            //return Ok(user);
        }
Exemplo n.º 8
0
        public ActionResult Index(LoginModel model)
        {
            try
            {
                var retorno = new BusinessLogin().VerificarLogin(new Entity.Login {
                    Usuario = model.Login.Usuario, Senha = model.Login.Senha
                });

                if (retorno.IsValido)
                {
                    Session[Constantes.USUARIO_LOGADO] = retorno.Entity;
                    return(RedirectToAction("Index", "Pedido"));
                }
                else
                {
                    model.Retorno = retorno;
                    return(View(model));
                }
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 9
0
 public IActionResult ChangePassword([FromBody] ChangePassword inputValues)
 {
     bl = _userService.ChangePassword(inputValues.OldPassword, inputValues.NewPassword,
                                      UserTempStorage.email, UserTempStorage.salt);
     return(Ok(inputValues));
 }
Exemplo n.º 10
0
        public IActionResult getAll()
        {
            var model = new BusinessLogin();

            return(Ok(model));
        }