示例#1
0
 public async Task Create(BitacoraITFConsulta model)
 {
     try
     {
         _db.dbSetBitacoraITFConsulta.Add(model);
         await _db.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
示例#2
0
        public async Task Update(BitacoraITFConsulta model)
        {
            try
            {
                var _model = await _db.dbSetBitacoraITFConsulta.FirstOrDefaultAsync(e => e.BitacoraITFConsultaId == model.BitacoraITFConsultaId);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
                                                                 public async Task <IHttpActionResult> Update([FromBody] BitacoraITFConsulta model)
                                                                 {
                                                                     if (!ModelState.IsValid)
                                                                     {
                                                                         return(BadRequest(ModelState));
                                                                     }

                                                                     try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                           await _entityRepo.Update(model);

                                                                           return(Ok("Registro actualizado exitosamente!")); }
                                                                     catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                           return(InternalServerError(e)); }
                                                                 }
                                                                 [Authorize] public async Task <IHttpActionResult> Create([FromBody] BitacoraITFConsulta model)
                                                                 {
                                                                     if (model == null ||
                                                                         String.IsNullOrEmpty(model.InformeTecnicoFinalId) || String.IsNullOrEmpty(model.ClavePersona))
                                                                     {
                                                                         return(BadRequest(ModelState));
                                                                     }
                                                                     model.FechaMovimiento = DateTime.Now;
                                                                     model.Ip = "indefinida";
                                                                     ServerVariables sv    = new ServerVariables();
                                                                     var             datos = await sv.GetIPasync();

                                                                     try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                           model.Ip = String.IsNullOrEmpty(datos.RemoteAddr) ? datos.ClientIP : datos.RemoteAddr; }
                                                                     catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); }

                                                                     try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                           await _entityRepo.Create(model);

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