Example #1
0
        public IngresoDto DeleteIngreso(IngresoDto ingreso)
        {
            var deletedIngreso = repository.SearchById(ingreso.Id);

            repository.DeleteIngreso(deletedIngreso);

            return(ingreso);
        }
Example #2
0
        /// <summary>
        /// Método que registra el ingreso del usuario a la universidad
        /// </summary>
        /// <returns></returns>
        ///
        public List <RespuestaIngresoDto> registrarIngreso(IngresoDto IngresoDto)
        {
            List <RespuestaIngresoDto> respuesta = new List <RespuestaIngresoDto>();
            int error = 0;

            if (string.IsNullOrEmpty(IngresoDto.codUsuario))
            {
                respuesta.Add(new RespuestaIngresoDto()
                {
                    codUsuario = Mensajes.codErrorUsuarioVacio,
                    sede       = "-1"
                });
                error = 1;
            }

            if (error == 0)
            {
                NegocioUsuario usuario           = new NegocioUsuario();
                Usuario        usuarioEncontrado = usuario.ConsultarPorId(Convert.ToInt32(IngresoDto.codUsuario));
                // pasa todas las validaciones realizo la activacion del usuario
                if (error == 0)
                {
                    using (UnitOfWork unitOfWork = new UnitOfWork())
                    {
                        RegistroIngreso nuevoIngreso = null;
                        usuarioEncontrado.codUsuario = usuarioEncontrado.codUsuario;
                        string fecha = DateTime.Now.ToString("yyyy-MM-dd");
                        string hora  = DateTime.Now.ToString("HH:mm:ss");

                        int[]    partes = hora.Split(new char[] { ':' }).Select(x => Convert.ToInt32(x)).ToArray();
                        TimeSpan tiempo = new TimeSpan(partes[0], partes[1], partes[2]);

                        nuevoIngreso = new RegistroIngreso()
                        {
                            codUsuario     = usuarioEncontrado.codUsuario,
                            codInstitucion = usuarioEncontrado.codInstitucion,
                            fecha          = Convert.ToDateTime(fecha),
                            hora           = tiempo,
                            temperatura    = IngresoDto.temperatura,
                            oxigenacion    = IngresoDto.oxigenacion
                        };

                        unitOfWork.EventosRepositorio.Adicionar(nuevoIngreso);
                        unitOfWork.Save();

                        respuesta.Add(new RespuestaIngresoDto()
                        {
                            codUsuario = Convert.ToString(usuarioEncontrado.codUsuario),
                            fecha      = Convert.ToDateTime(fecha),
                            hora       = tiempo,
                            sede       = nuevoIngreso.codInstitucion
                        });
                    }
                }
            }

            return(respuesta);
        }
Example #3
0
        public async Task <IActionResult> Post(IngresoDto ingresoDto)
        {
            var ingreso = _mapper.Map <Ingreso>(ingresoDto);
            await _ingresoService.InsertIngreso(ingreso);

            ingresoDto = _mapper.Map <IngresoDto>(ingreso);
            var respose = new ApiResponse <IngresoDto>(ingresoDto);

            return(Ok(ingreso));
        }
Example #4
0
        public async Task <IActionResult> Put(int Id, IngresoDto ingresoDto)
        {
            var ingreso = _mapper.Map <Ingreso>(ingresoDto);

            ingreso.Id = Id;
            var result = await _ingresoService.UpdateIngreso(ingreso);

            var respose = new ApiResponse <bool>(result);

            return(Ok(respose));
        }
Example #5
0
        public IngresoDto AddIngreso(IngresoDto ingreso)
        {
            repository.AddIngreso(new Ingreso()
            {
                Monto       = ingreso.Monto,
                Descripcion = ingreso.Descripcion,
                FuenteId    = ingreso.Fuente.Id,
                Fecha       = DateTime.ParseExact(ingreso.Fecha, "dd/MM/yyyy", CultureInfo.InvariantCulture)
            });

            return(ingreso);
        }
Example #6
0
        public IHttpActionResult RegistrarIngreso([FromBody] IngresoDto ingreso)
        {
            try
            {
                NegocioEventos             negocioEvento     = new NegocioEventos();
                List <RespuestaIngresoDto> ingresoResultante = negocioEvento.registrarIngreso(ingreso);

                return(Content(HttpStatusCode.OK, ingresoResultante));
            }
            catch (ExceptionControlada ex)
            {
                log.EscribirLogError(ex.Message, ex);
                return(Content(HttpStatusCode.NotFound, new ApiException(HttpStatusCode.NotFound, ex.Message, ex)));
            }
            catch (Exception ex)
            {
                log.EscribirLogError("Error al activar usuario", ex);
                return(Content(HttpStatusCode.InternalServerError, Mensajes.DescFallo));
            }
        }