public async Task Create(LogBitacora model) { try { _db.bdSetLogBitacora.Add(model); await _db.SaveChangesAsync(); } catch (Exception e) { throw new Exception(e.Message, e); } }
public async Task Update(LogBitacora model) { try { var _model = await _db.bdSetLogBitacora.FirstOrDefaultAsync(e => e.Id == model.Id); 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> GetByIdDetails3(long Id) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); try { log.Info(new MDCSet(this.ControllerContext.RouteData)); LogBitacoraRepository logBita = new LogBitacoraRepository(); LogBitacora newLog = new LogBitacora(); newLog.Date = DateTime.Now; newLog.Thread = "100"; //se coloca uno fijo de momento newLog.Level = "INFO"; //se coloca fijo de momento newLog.Logger = "INEEL.WebAPI.Controllers.MT.SoftwarePersonalController"; newLog.Action = "GET-SoftwarePersonal-GetByIdDetails3TIME"; newLog.User = "******"; newLog.Ip = "192.168.0.1"; //nos estamos ahorrando tiempo en obtener la ip real await logBita.Create(newLog); var entity = await _repositoryMt.GetByIdDetails(Id); stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); return(Ok(elapsedTime)); //return Ok(entity); } catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); // ex||error||e||etc|| new Exception("Custom description Error") return(InternalServerError(e)); } }