Ejemplo n.º 1
0
        public async Task Update(HistorialPI historial)
        {
            try
            {
                if (historial.Adjunto != null)
                {
                    if (historial.Adjunto.AdjuntoId == 0)
                    {
                        Adjunto key = await new AdjuntoRepository().CreateAd(historial.Adjunto);
                        historial.AdjuntoId         = key.AdjuntoId;
                        historial.Adjunto.AdjuntoId = key.AdjuntoId;
                    }
                }
                var _historial = await _pictx.Historial.FirstOrDefaultAsync(e => e.HistorialPIId == historial.HistorialPIId);

                if (_historial != null)
                {
                    _pictx.Entry(_historial).CurrentValues.SetValues(historial);
                    await _pictx.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> Update(HistorialPI historial)
        {
            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                await _piRepo.Update(historial);

                return(Ok("Registro actualizado exitosamente!"));
            }
            catch (DbUpdateConcurrencyException e)
            {
                log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                return(StatusCode(HttpStatusCode.NoContent));
            }
        }
Ejemplo n.º 3
0
        public async Task Create(HistorialPI historial)
        {
            try
            {
                DateTime hoy = DateTime.Now;
                historial.FechaRegistroAccion = hoy;

                _pictx.Historial.Add(historial);
                await _pictx.SaveChangesAsync();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> Create(HistorialPI historial)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                log.Info(new MDCSet(this.ControllerContext.RouteData));
                await _piRepo.Create(historial);

                return(Ok("Registro creado exitosamente!"));
            }
            catch (Exception e)
            {
                log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                return(InternalServerError(e));
            }
        }