Esempio n. 1
0
        public async Task <IActionResult> CrearTurno([FromBody] TurnoResource turnoResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var turno = mapper.Map <TurnoResource, Turno>(turnoResource);

            repository.Add(turno);
            await unitOfWork.CompleteAsync();

            var resultado = await repository.GetTurno(turno.Id);

            var restmp = mapper.Map <Turno, TurnoResource>(resultado);

            return(Ok(restmp));
        }
Esempio n. 2
0
        public async Task <IActionResult> ActualizarTurno(int id, [FromBody] TurnoResource turnoResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var turno = await repository.GetTurno(id);

            if (turno == null)
            {
                return(NotFound());
            }

            turno = mapper.Map <TurnoResource, Turno>(turnoResource, turno);

            await unitOfWork.CompleteAsync();

            var actualizacion = await repository.GetTurno(turno.Id);

            var resultado = mapper.Map <Turno, TurnoResource>(actualizacion);

            return(Ok(resultado));
        }