public IActionResult GetCarteraById([FromBody] CarteraUserData carteraUser)
        {
            var cartera = carteraService.GetCarteraById(carteraUser.Cartera.Id);

            if (cartera == null)
            {
                return(BadRequest(new { message = "Cartera invalida" }));
            }

            return(Ok(cartera));
        }
        public IActionResult DisableCartera([FromBody] CarteraUserData carteraUser)
        {
            var user = _userService.GetUserByName(carteraUser.NombreUser);

            if (user == null)
            {
                return(BadRequest(new { message = "Nombre de usuario invalido" }));
            }

            var cartera = carteraService.GetCarteraById(carteraUser.Cartera.Id);

            if (cartera == null)
            {
                return(BadRequest(new { message = "Cartera invalida" }));
            }

            return(Ok(carteraService.DisableCartera(cartera)));
        }
        public IActionResult AddCarteraUser([FromBody] CarteraUserData carteraUser)
        {
            var user = _userService.GetUserByName(carteraUser.NombreUser);

            if (user == null)
            {
                return(BadRequest(new { message = "Nombre de usuario invalido" }));
            }

            if (carteraUser.Cartera.Nombre == null)
            {
                return(BadRequest(new { message = "Informacion insuficiente" }));
            }

            if (carteraService.ExistCartera(carteraUser))
            {
                return(BadRequest(new { message = "La Cartera ya existe" }));
            }

            return(Ok(carteraService.AddCartera(carteraUser.Cartera, user.Id)));
        }
Esempio n. 4
0
 public bool ExistCartera(CarteraUserData input)
 {
     return(CarterasUser(input.NombreUser).Where(x => x.Nombre.Equals(input.Cartera.Nombre.Trim())).FirstOrDefault() != null);
 }