public async Task <IActionResult> Edit(string id, FondoFinanciamiento fondoFinanciamiento) { try { if (!string.IsNullOrEmpty(id)) { var response = await apiServicio.EditarAsync(id, fondoFinanciamiento, new Uri(WebApp.BaseAddressRM), "api/FondoFinanciamiento"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), EntityID = string.Format("{0} : {1}", "Fondo de Financiamiento", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro Fondo de Financiamiento", UserName = "******" }); return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}")); } ViewData["Error"] = response.Message; return(View(fondoFinanciamiento)); } return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.RegistroNoExiste}")); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un Fondo de Financiamiento", 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> PostFondoFinanciamiento([FromBody] FondoFinanciamiento fondoFinanciamiento) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(fondoFinanciamiento); if (!respuesta.IsSuccess) { db.FondoFinanciamiento.Add(fondoFinanciamiento); 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(FondoFinanciamiento fondoFinanciamiento) { Response response = new Response(); try { response = await apiServicio.InsertarAsync(fondoFinanciamiento, new Uri(WebApp.BaseAddressRM), "api/FondoFinanciamiento/InsertarFondoFinanciamiento"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado un Fondo de Financiamiento", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "Fondo de Financiamiento:", fondoFinanciamiento.IdFondoFinanciamiento), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(fondoFinanciamiento)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando Fondo de Financiamiento", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> Edit(string id, FondoFinanciamiento fondoFinanciamiento) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, fondoFinanciamiento, new Uri(WebApp.BaseAddressRM), "api/FondoFinanciamiento"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), EntityID = string.Format("{0} : {1}", "Fondo de Financiamiento", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro Fondo de Financiamiento", UserName = "******" }); return(RedirectToAction("Index")); } } return(View(fondoFinanciamiento)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Editando un Fondo de Financiamiento", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public Response Existe(FondoFinanciamiento fondoFinanciamiento) { var bdd = fondoFinanciamiento.Nombre.ToUpper().TrimEnd().TrimStart(); var loglevelrespuesta = db.FondoFinanciamiento.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 <IActionResult> Create(FondoFinanciamiento fondoFinanciamiento) { try { var response = await apiServicio.InsertarAsync(fondoFinanciamiento, new Uri(WebApp.BaseAddressRM), "api/FondoFinanciamiento/InsertarFondoFinanciamiento"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), ExceptionTrace = null, Message = "Se ha creado un Fondo de Financiamiento", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "Fondo de Financiamiento:", fondoFinanciamiento.IdFondoFinanciamiento) }); return(this.Redireccionar($"{Mensaje.Informacion}|{Mensaje.Satisfactorio}")); } ViewData["Error"] = response.Message; return(View(fondoFinanciamiento)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppRM), Message = "Creando Fondo de Financiamiento", 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> PutFondoFinanciamiento([FromRoute] int id, [FromBody] FondoFinanciamiento fondoFinanciamiento) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var fondoFinanciamientoActualizar = await db.FondoFinanciamiento.Where(x => x.IdFondoFinanciamiento == id).FirstOrDefaultAsync(); if (fondoFinanciamientoActualizar != null) { try { fondoFinanciamientoActualizar.Nombre = fondoFinanciamiento.Nombre; db.FondoFinanciamiento.Update(fondoFinanciamientoActualizar); 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 }); } }