public async Task <Response> PostLibroActivoFijo([FromBody] LibroActivoFijo libroActivoFijo) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(libroActivoFijo); if (!respuesta.IsSuccess) { db.LibroActivoFijo.Add(libroActivoFijo); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio }); } return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.SwRm), ExceptionTrace = ex, Message = Mensaje.Excepcion, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "", }); return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } }
public async Task <IActionResult> Edit(string id, LibroActivoFijo LibroActivoFijo) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, LibroActivoFijo, new Uri(WebApp.BaseAddressRM), "api/LibroActivoFijo"); if (!response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), EntityID = string.Format("{0} : {1}", "Sistema", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro sistema", UserName = "******" }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(LibroActivoFijo)); } return(BadRequest()); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un LibroActivoFijo", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> Create(LibroActivoFijo LibroActivoFijo) { Response response = new Response(); try { response = await apiServicio.InsertarAsync(LibroActivoFijo, new Uri(WebApp.BaseAddressRM), "api/LibroActivoFijo/InsertarLibroActivoFijo"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado un Libro de Activo Fijo", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "LibroActivoFijo:", LibroActivoFijo.IdLibroActivoFijo), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(LibroActivoFijo)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando LibroActivoFijo", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public Response Existe(LibroActivoFijo libroActivoFijo) { var LibroActivoFijoRespuesta = db.LibroActivoFijo.Where(p => p.IdSucursal == libroActivoFijo.IdSucursal).FirstOrDefault(); if (LibroActivoFijoRespuesta != null) { return(new Response { IsSuccess = true, Message = Mensaje.ExisteRegistro, Resultado = null, }); } return(new Response { IsSuccess = false, Resultado = LibroActivoFijoRespuesta, }); }
public async Task <Response> PutLibroActivoFijo([FromRoute] int id, [FromBody] LibroActivoFijo libroActivoFijo) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido, }); } var LibroActivoFijoActualizar = await db.LibroActivoFijo.Where(x => x.IdLibroActivoFijo == id).FirstOrDefaultAsync(); if (LibroActivoFijoActualizar != null) { try { LibroActivoFijoActualizar.IdSucursal = libroActivoFijo.IdSucursal; db.LibroActivoFijo.Update(LibroActivoFijoActualizar); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.ModeloInvalido, }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.SwRm), ExceptionTrace = ex, Message = Mensaje.Excepcion, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "", }); return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } } return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro }); } catch (Exception) { return(new Response { IsSuccess = false, Message = Mensaje.Excepcion }); } }