public async Task <Response> PostTrayectoriaLaboral([FromBody] CandidatoTrayectoriaLaboral candidatoTrayectoriaLaboral) { try { var respuesta = ExisteTrayectoria(candidatoTrayectoriaLaboral); if (!respuesta.IsSuccess) { db.CandidatoTrayectoriaLaboral.Add(candidatoTrayectoriaLaboral); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio }); } return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro, }); } catch (Exception ex) { return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } }
public async Task <IActionResult> CreateExperiencia(ViewModelSeleccionPersonal viewModelSeleccionPersonal) { try { var candidato = ObtenerCandidato(); var candidatoTrayectoria = new CandidatoTrayectoriaLaboral() { FechaInicio = viewModelSeleccionPersonal.fechainicio, FechaFin = viewModelSeleccionPersonal.fechahasta, Institucion = viewModelSeleccionPersonal.Instituacion, IdCandidato = candidato.IdCandidato }; candidatoTrayectoria.IdCandidato = candidato.IdCandidato; var response = await apiServicio.InsertarAsync(candidatoTrayectoria, new Uri(WebApp.BaseAddress), "api/Candidatos/InsertarTrayectoriaLaboral"); if (response.IsSuccess) { return(RedirectToAction("IndexExperiencia")); } ViewData["Error"] = Mensaje.ExisteEmpleado; return(View(candidatoTrayectoria)); } catch (Exception) { throw; } }
private Response ExisteTrayectoria(CandidatoTrayectoriaLaboral candidatoTrayectoriaLaboral) { var fechaInicio = candidatoTrayectoriaLaboral.FechaInicio; var fechaFin = candidatoTrayectoriaLaboral.FechaFin; var Empresa = candidatoTrayectoriaLaboral.Institucion; var IdCandidato = candidatoTrayectoriaLaboral.IdCandidato; var TrayectoriaLaboralrespuesta = db.CandidatoTrayectoriaLaboral.Where(p => p.IdCandidato == IdCandidato && p.FechaFin == fechaFin && p.FechaInicio == fechaInicio && p.Institucion == Empresa).FirstOrDefault(); if (TrayectoriaLaboralrespuesta != null) { return(new Response { IsSuccess = true, Message = Mensaje.ExisteRegistro, Resultado = TrayectoriaLaboralrespuesta, }); } return(new Response { IsSuccess = false, Resultado = TrayectoriaLaboralrespuesta, }); }