예제 #1
0
        public ActionResult <RestauranteViewModel> Post(RestauranteInputModel restauranteInput)
        {
            Restaurante restaurante = mapearRestaurante(restauranteInput);
            var         respuesta   = _restauranteService.Guardar(restaurante);

            if (respuesta.Error)
            {
                return(BadRequest(respuesta.Mensaje));
            }
            return(Ok(respuesta.Restaurante));
        }
예제 #2
0
        private Restaurante mapearRestaurante(RestauranteInputModel restauranteInput)
        {
            Restaurante restaurante = new Restaurante();

            restaurante.NombreRestaurante = restauranteInput.NombreRestaurante;
            restaurante.Direccion         = restauranteInput.Direccion;
            restaurante.Evaluacion        = restauranteInput.Evaluacion;
            restaurante.Nit    = restauranteInput.Nit;
            restaurante.Estado = restauranteInput.Estado;
            restaurante.Id     = restauranteInput.Id;
            return(restaurante);
        }
예제 #3
0
        private Restaurante MapearRestaurante(RestauranteInputModel restauranteInput)
        {
            var restaurante = new Restaurante
            {
                Codigo    = restauranteInput.Codigo,
                Nombre    = restauranteInput.Nombre,
                Direccion = restauranteInput.Direccion,
                Telefono  = restauranteInput.Telefono
            };

            return(restaurante);
        }
        public async Task <ActionResult <RestauranteViewModel> > Post(RestauranteInputModel restauranteInput)
        {
            Restaurante restaurante = MapearRestaurante(restauranteInput);
            var         response    = _restauranteService.Guardar(restaurante);

            if (response.Error)
            {
                return(BadRequest(response.Mensaje));
            }
            await _hubContext.Clients.All.SendAsync("RegistrarRestaurante", new RestauranteViewModel(response.Restaurante));

            return(Ok(response.Restaurante));
        }
예제 #5
0
        private Restaurante mapearRestaurante(RestauranteInputModel restauranteInput)
        {
            var restaurante = new Restaurante
            {
                Estado            = restauranteInput.Estado,
                NombreRestaurante = restauranteInput.NombreRestaurante,
                Direccion         = restauranteInput.Direccion,
                Evaluacion        = restauranteInput.Evaluacion,
                Nit = restauranteInput.Nit,
                Id  = restauranteInput.Id
            };

            return(restaurante);
        }
예제 #6
0
        public ActionResult <RestauranteViewModel> Put(string Nit, RestauranteInputModel restauranteInput)
        {
            Restaurante restaurante = mapearRestaurante(restauranteInput);
            var         nit         = _restauranteService.BuscarPorNit(restaurante.Nit);

            if (nit == null)
            {
                return(BadRequest("No encontrado"));
            }
            else
            {
                string respuesta = _restauranteService.Modificar(restaurante);
                return(Ok(respuesta));
            }
        }
        private Restaurante MapearRestaurante(RestauranteInputModel restauranteInput)
        {
            var restaurante = new Restaurante();

            restaurante.NIT               = restauranteInput.Nit;
            restaurante.Nombre            = restauranteInput.Nombre;
            restaurante.Propietario       = restauranteInput.Propietario;
            restaurante.Direccion         = restauranteInput.Direccion;
            restaurante.CantidadPersonal  = restauranteInput.CantidadPersonal;
            restaurante.Telefono          = restauranteInput.Telefono;
            restaurante.Email             = restauranteInput.Email;
            restaurante.Sedes             = restauranteInput.Sedes;
            restaurante.AñoFuncionamiento = restauranteInput.AñoFuncionamiento;
            restaurante.Especialidad      = restauranteInput.Especialidad;
            return(restaurante);
        }
예제 #8
0
        public ActionResult <RestauranteViewModel> Post(RestauranteInputModel restauranteInput)
        {
            Restaurante restaurante = MapearRestaurante(restauranteInput);
            var         response    = _restauranteService.Guardar(restaurante);

            if (response.Error)
            {
                ModelState.AddModelError("Guardar Restaurante", response.Mensaje);
                var problemDetails = new ValidationProblemDetails(ModelState)
                {
                    Status = StatusCodes.Status400BadRequest,
                };
                return(BadRequest(problemDetails));
            }
            return(Ok(response.Restaurante));
        }
예제 #9
0
        private Restaurante MapearRestaurante(RestauranteInputModel restauranteInput)
        {
            var restaurante = new Restaurante
            {
                Nit               = restauranteInput.Nit,
                Nombre            = restauranteInput.Nombre,
                Pais              = restauranteInput.Pais,
                Ciudad            = restauranteInput.Ciudad,
                Direccion         = restauranteInput.Direccion,
                Barrio            = restauranteInput.Barrio,
                Telefono          = restauranteInput.Telefono,
                CorreoElectronico = restauranteInput.CorreoElectronico,
                SitioWeb          = restauranteInput.SitioWeb
            };

            return(restaurante);
        }
        public ActionResult <RestauranteViewModel> EditarRestaurante(RestauranteInputModel restauranteInput)
        {
            Restaurante restaurante = MapearRestaurante(restauranteInput);
            var         response    = _restauranteService.EditarRestaurante(restaurante);

            if (response.Error)
            {
                ModelState.AddModelError("Error al editar el Restaurante", response.Mensaje);
                var problemas = new ValidationProblemDetails(ModelState);
                if (response.Estado == "NoExiste")
                {
                    problemas.Status = StatusCodes.Status404NotFound;
                }

                if (response.Estado == "Error")
                {
                    problemas.Status = StatusCodes.Status500InternalServerError;
                }

                return(BadRequest(problemas));
            }
            return(Ok(response.Restaurante));
        }