public async Task <IActionResult> Edit(string id, MotivoAsiento motivoAsiento) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, motivoAsiento, new Uri(WebApp.BaseAddressRM), "api/MotivoAsiento"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), EntityID = string.Format("{0} : {1}", "Motivo de Asiento", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro Motivo de Asiento", UserName = "******" }); return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}")); } ViewData["Error"] = response.Message; ViewData["ConfiguracionContabilidad"] = new SelectList((await apiServicio.Listar <ConfiguracionContabilidad>(new Uri(WebApp.BaseAddressRM), "api/ConfiguracionContabilidad/ListarConfiguracionContabilidad")).Select(c => new { IdConfiguracionContabilidad = c.IdConfiguracionContabilidad, Nombre = $"Valor Debe: {c.ValorD}, Valor Haber: {c.ValorH}" }), "IdConfiguracionContabilidad", "Nombre"); return(View(motivoAsiento)); } return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.RegistroNoExiste}")); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un Motivo de Asiento", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorEditar}")); } }
public async Task <Response> PostMotivoAsiento([FromBody] MotivoAsiento motivoAsiento) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(motivoAsiento); if (!respuesta.IsSuccess) { db.MotivoAsiento.Add(motivoAsiento); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio }); } return(new Response { IsSuccess = false, 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, }); } }
public async Task <IActionResult> Create(MotivoAsiento motivoAsiento) { Response response = new Response(); try { response = await apiServicio.InsertarAsync(motivoAsiento, new Uri(WebApp.BaseAddressRM), "api/MotivoAsiento/InsertarMotivoAsiento"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado un Motivo de Asiento", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "Motivo de Asiento:", motivoAsiento.IdMotivoAsiento), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(motivoAsiento)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando Motivo de Asiento", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> Edit(string id, MotivoAsiento motivoAsiento) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, motivoAsiento, new Uri(WebApp.BaseAddressRM), "api/MotivoAsiento"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), EntityID = string.Format("{0} : {1}", "Motivo de Asiento", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro Motivo de Asiento", UserName = "******" }); return(RedirectToAction("Index")); } } return(View(motivoAsiento)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un Motivo de Asiento", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public Response Existe(MotivoAsiento motivoAsiento) { var bdd = motivoAsiento.Descripcion.ToUpper().TrimEnd().TrimStart(); var loglevelrespuesta = db.MotivoAsiento.Where(p => p.Descripcion.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 <IActionResult> Create(MotivoAsiento motivoAsiento) { try { var response = await apiServicio.InsertarAsync(motivoAsiento, new Uri(WebApp.BaseAddressRM), "api/MotivoAsiento/InsertarMotivoAsiento"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado un Motivo de Asiento", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "Motivo de Asiento:", motivoAsiento.IdMotivoAsiento) }); return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}")); } ViewData["Error"] = response.Message; ViewData["ConfiguracionContabilidad"] = new SelectList((await apiServicio.Listar <ConfiguracionContabilidad>(new Uri(WebApp.BaseAddressRM), "api/ConfiguracionContabilidad/ListarConfiguracionContabilidad")).Select(c => new { IdConfiguracionContabilidad = c.IdConfiguracionContabilidad, Nombre = $"Valor Debe: {c.ValorD}, Valor Haber: {c.ValorH}" }), "IdConfiguracionContabilidad", "Nombre"); return(View(motivoAsiento)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando Motivo de Asiento", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCrear}")); } }
public async Task <Response> PutMotivoAsiento([FromRoute] int id, [FromBody] MotivoAsiento motivoAsiento) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var motivoAsientoActualizar = await db.MotivoAsiento.Where(x => x.IdMotivoAsiento == id).FirstOrDefaultAsync(); if (motivoAsientoActualizar != null) { try { motivoAsientoActualizar.Descripcion = motivoAsiento.Descripcion; db.MotivoAsiento.Update(motivoAsientoActualizar); 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 }); } }