public Response Crear(AreaConocimiento areaConocimiento) { try { var respuesta = Existe(areaConocimiento); if (!respuesta.IsSuccess) { areaConocimiento.Descripcion = areaConocimiento.Descripcion.TrimStart().TrimEnd().ToUpper(); db.Add(areaConocimiento); db.SaveChanges(); return(new Response { IsSuccess = true, Message = "Ok", }); } else { return(new Response { IsSuccess = false, Message = "Existe un areaConocimiento con igual nombre...", }); } } catch (Exception ex) { return(new Response { IsSuccess = false, Message = ex.Message, }); } }
public async Task <Response> PostAreaConocimiento([FromBody] AreaConocimiento AreaConocimiento) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = "" }); } var respuesta = Existe(AreaConocimiento); if (!respuesta.IsSuccess) { db.AreaConocimiento.Add(AreaConocimiento); 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 = 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(AreaConocimiento areaConocimiento) { if (!ModelState.IsValid) { InicializarMensaje(null); return(View(areaConocimiento)); } Response response = new Response(); try { response = await apiServicio.InsertarAsync(areaConocimiento, new Uri(WebApp.BaseAddress), "api/AreasConocimientos/InsertarAreaConocimiento"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), ExceptionTrace = null, Message = "Se ha creado un área de conocimiento", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "Areas Conocimientos:", areaConocimiento.IdAreaConocimiento), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(areaConocimiento)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Creando Area de Conocimiento", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> Edit(string id, AreaConocimiento areaConocimiento) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, areaConocimiento, new Uri(WebApp.BaseAddress), "/api/AreasConocimientos"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), EntityID = string.Format("{0} : {1}", "Area de Conocimiento", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un área de conocimiento", UserName = "******" }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(areaConocimiento)); } return(BadRequest()); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Editando un área de conocimiento", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> AdicionarAreaConocimientoLocal(IndiceOcupacionalAreaConocimiento indiceOcupacionalAreaConocimiento) { Response response = new Response(); try { var areaConocimiento = new AreaConocimiento { IdAreaConocimiento = indiceOcupacionalAreaConocimiento.IdAreaConocimiento, }; Singleton.Instance.ListaAreaConocimientos.Add(areaConocimiento); return(await Create("")); } catch (Exception ex) { return(BadRequest()); } }
private Response Existe(AreaConocimiento AreaConocimiento) { var bdd = AreaConocimiento.Descripcion.ToUpper().TrimEnd().TrimStart(); var AreaConocimientorespuesta = db.AreaConocimiento.Where(p => p.Descripcion.ToUpper().TrimStart().TrimEnd() == bdd).FirstOrDefault(); if (AreaConocimientorespuesta != null) { return(new Response { IsSuccess = true, Message = Mensaje.ExisteRegistro, Resultado = null, }); } return(new Response { IsSuccess = false, Resultado = AreaConocimientorespuesta, }); }
public Response Existe(AreaConocimiento areaConocimiento) { var respuestaNivelDesarrollo = db.AreaConocimiento.Where(p => p.Descripcion.ToUpper() == areaConocimiento.Descripcion.TrimStart().TrimEnd().ToUpper()).FirstOrDefault(); if (respuestaNivelDesarrollo != null) { return(new Response { IsSuccess = true, Message = "Existe areaConocimiento de igual nombre", Resultado = null, }); } return(new Response { IsSuccess = false, Message = "No existe areaConocimiento...", Resultado = db.AreaConocimiento.Where(p => p.IdAreaConocimiento == areaConocimiento.IdAreaConocimiento).FirstOrDefault(), }); }
public async Task <Response> PutAreaConocimiento([FromRoute] int id, [FromBody] AreaConocimiento AreaConocimiento) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var existe = Existe(AreaConocimiento); if (existe.IsSuccess) { return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro, }); } var AreaConocimientoActualizar = await db.AreaConocimiento.Where(x => x.IdAreaConocimiento == id).FirstOrDefaultAsync(); if (AreaConocimientoActualizar != null) { try { AreaConocimientoActualizar.Descripcion = AreaConocimiento.Descripcion; db.AreaConocimiento.Update(AreaConocimientoActualizar); 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 = 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 }); } }