public async Task <Response> PostActivoFijoMotivoBaja([FromBody] ActivoFijoMotivoBaja activoFijoMotivoBaja) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(activoFijoMotivoBaja); if (!respuesta.IsSuccess) { db.ActivoFijoMotivoBaja.Add(activoFijoMotivoBaja); 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> Create(ActivoFijoMotivoBaja ActivoFijoMotivoBaja) { Response response = new Response(); try { response = await apiServicio.InsertarAsync(ActivoFijoMotivoBaja, new Uri(WebApp.BaseAddressRM), "api/ActivoFijoMotivoBaja/InsertarActivoFijoMotivoBaja"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado un Activo Fijo Motivo Baja", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "ActivoFijoMotivoBaja:", ActivoFijoMotivoBaja.IdActivoFijoMotivoBaja), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(ActivoFijoMotivoBaja)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando Activo Fijo Motivo Baja", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> Edit(string id, ActivoFijoMotivoBaja ActivoFijoMotivoBaja) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, ActivoFijoMotivoBaja, new Uri(WebApp.BaseAddressRM), "api/ActivoFijoMotivoBaja"); 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")); } } return(BadRequest()); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un ActivoFijoMotivoBaja", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public Response Existe(ActivoFijoMotivoBaja activoFijoMotivoBaja) { var bdd = activoFijoMotivoBaja.Nombre.ToUpper().TrimEnd().TrimStart(); var loglevelrespuesta = db.ActivoFijoMotivoBaja.Where(p => p.Nombre.ToUpper().TrimStart().TrimEnd() == bdd).FirstOrDefault(); if (loglevelrespuesta != null) { return(new Response { IsSuccess = true, Message = Mensaje.ExisteRegistro, Resultado = null, }); } return(new Response { IsSuccess = false, Resultado = loglevelrespuesta, }); }
public async Task <Response> PutActivoFijoMotivoBaja([FromRoute] int id, [FromBody] ActivoFijoMotivoBaja activoFijoMotivoBaja) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido, }); } var ActivoFijoMotivoBajaActualizar = await db.ActivoFijoMotivoBaja.Where(x => x.IdActivoFijoMotivoBaja == id).FirstOrDefaultAsync(); if (ActivoFijoMotivoBajaActualizar != null) { try { ActivoFijoMotivoBajaActualizar.Nombre = activoFijoMotivoBaja.Nombre; db.ActivoFijoMotivoBaja.Update(ActivoFijoMotivoBajaActualizar); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio, }); } 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 }); } }