public async Task <Response> PostTrabajoEquipoIniciativaLiderazgo([FromBody] TrabajoEquipoIniciativaLiderazgo TrabajoEquipoIniciativaLiderazgo) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(TrabajoEquipoIniciativaLiderazgo); if (!respuesta.IsSuccess) { db.TrabajoEquipoIniciativaLiderazgo.Add(TrabajoEquipoIniciativaLiderazgo); 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.SwTH), ExceptionTrace = ex.Message, 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(TrabajoEquipoIniciativaLiderazgo TrabajoEquipoIniciativaLiderazgo) { if (!ModelState.IsValid) { InicializarMensaje(null); return(View(TrabajoEquipoIniciativaLiderazgo)); } Response response = new Response(); try { response = await apiServicio.InsertarAsync(TrabajoEquipoIniciativaLiderazgo, new Uri(WebApp.BaseAddress), "api/TrabajosDeEquipoIniciativaLiderazgo/InsertarTrabajoEquipoIniciativaLiderazgo"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), ExceptionTrace = null, Message = "Se ha creado un trabajo de equipo iniciativa liderazgo", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "TrabajoEquipoIniciativaLiderazgo:", TrabajoEquipoIniciativaLiderazgo.IdTrabajoEquipoIniciativaLiderazgo), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(TrabajoEquipoIniciativaLiderazgo)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Creando trabajo de equipo iniciativa liderazgo", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> Edit(string id, TrabajoEquipoIniciativaLiderazgo TrabajoEquipoIniciativaLiderazgo) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, TrabajoEquipoIniciativaLiderazgo, new Uri(WebApp.BaseAddress), "api/TrabajosDeEquipoIniciativaLiderazgo"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), 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(TrabajoEquipoIniciativaLiderazgo)); } return(BadRequest()); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Editando un trabajo de equipo iniciativa liderazgo", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
private Response Existe(TrabajoEquipoIniciativaLiderazgo TrabajoEquipoIniciativaLiderazgo) { var bdd = TrabajoEquipoIniciativaLiderazgo.Nombre; var TrabajoEquipoIniciativaLiderazgorespuesta = db.TrabajoEquipoIniciativaLiderazgo.Where(p => p.Nombre == bdd).FirstOrDefault(); if (TrabajoEquipoIniciativaLiderazgorespuesta != null) { return(new Response { IsSuccess = true, Message = Mensaje.ExisteRegistro, Resultado = null, }); } return(new Response { IsSuccess = false, Resultado = TrabajoEquipoIniciativaLiderazgorespuesta, }); }
public async Task <Response> PutTrabajoEquipoIniciativaLiderazgo([FromRoute] int id, [FromBody] TrabajoEquipoIniciativaLiderazgo TrabajoEquipoIniciativaLiderazgo) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var existe = Existe(TrabajoEquipoIniciativaLiderazgo); if (existe.IsSuccess) { return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro, }); } var TrabajoEquipoIniciativaLiderazgoActualizar = await db.TrabajoEquipoIniciativaLiderazgo.Where(x => x.IdTrabajoEquipoIniciativaLiderazgo == id).FirstOrDefaultAsync(); if (TrabajoEquipoIniciativaLiderazgoActualizar != null) { try { TrabajoEquipoIniciativaLiderazgoActualizar.Nombre = TrabajoEquipoIniciativaLiderazgo.Nombre; await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio, }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.SwTH), ExceptionTrace = ex.Message, 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 }); } }