public async Task <IActionResult> Create(int IdActividadesGestionCambio) { var AvanceGestionCambio = new AvanceGestionCambio { IdActividadesGestionCambio = IdActividadesGestionCambio, Fecha = DateTime.Now }; return(View(AvanceGestionCambio)); }
public async Task <IActionResult> Edit(string id, AvanceGestionCambio AvanceGestionCambio) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, AvanceGestionCambio, new Uri(WebApp.BaseAddress), "/api/AvancesGestionCambio"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), EntityID = string.Format("{0} : {1}", "Avance de gestión de cambio", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un avance de gestión de cambio", UserName = "******" }); return(RedirectToAction("Index", new { IdActividadesGestionCambio = AvanceGestionCambio.IdActividadesGestionCambio })); } ViewData["Error"] = response.Message; return(View(AvanceGestionCambio)); } return(BadRequest()); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Editando una actividad gestión de cambio", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public async Task <IActionResult> Index(int IdActividadesGestionCambio) { try { if (IdActividadesGestionCambio != 0) { var avancesGestionCambio = new AvanceGestionCambio { IdActividadesGestionCambio = Convert.ToInt32(IdActividadesGestionCambio), }; var viewModelAvanceGestionCambio = new AvanceGestionCambioViewModel { IdActividadesGestionCambio = Convert.ToInt32(IdActividadesGestionCambio), ListaAvancesGestionCambio = await apiServicio.Listar <AvanceGestionCambio>(avancesGestionCambio, new Uri(WebApp.BaseAddress), "/api/AvancesGestionCambio/ListarAvanceGestionCambioconIdActividad") }; return(View(viewModelAvanceGestionCambio)); } ViewData["Mensaje"] = "Ir a la página de Plan Gestión Cambio"; return(View("NoExisteElemento")); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Listando una avance de gestión de cambio", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.NetActivity), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
private Response Existe(AvanceGestionCambio AvanceGestionCambio) { var AvanceGestionCambiorespuesta = db.AvanceGestionCambio.Where(p => p.Fecha == AvanceGestionCambio.Fecha && p.Indicadorreal == AvanceGestionCambio.Indicadorreal && p.IdActividadesGestionCambio == AvanceGestionCambio.IdActividadesGestionCambio ).FirstOrDefault(); if (AvanceGestionCambiorespuesta != null) { return(new Response { IsSuccess = true, Message = Mensaje.ExisteRegistro, Resultado = AvanceGestionCambiorespuesta, }); } return(new Response { IsSuccess = false, Resultado = AvanceGestionCambiorespuesta, }); }
public async Task <List <AvanceGestionCambio> > ListarAvanceGestionCambioconIdActividad([FromBody] AvanceGestionCambio AvanceGestionCambio) { try { return(await db.AvanceGestionCambio.Where(m => m.IdActividadesGestionCambio == AvanceGestionCambio.IdActividadesGestionCambio).ToListAsync()); } 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 List <AvanceGestionCambio>()); } }
public async Task <Response> PostAvanceGestionCambio([FromBody] AvanceGestionCambio AvanceGestionCambio) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = "" }); } if (AvanceGestionCambio.Indicadorreal == 0) { return(new Response { IsSuccess = false, Message = "El indicador real no puede ser cero" }); } if (AvanceGestionCambio.Fecha <= DateTime.Today) { return(new Response { IsSuccess = false, Message = "La fecha de inicio no puede ser menor o igual que la fecha de hoy" }); } string fecha = AvanceGestionCambio.Fecha.DayOfWeek.ToString(); if (fecha.Equals("Saturday") || fecha.Equals("Sunday")) { return(new Response { IsSuccess = false, Message = "La fecha de inicio no puede ser fin de semana" }); } ActividadesGestionCambio Actividades = db.ActividadesGestionCambio.Find(AvanceGestionCambio.IdActividadesGestionCambio); if (Actividades.FechaInicio > AvanceGestionCambio.Fecha) { return(new Response { IsSuccess = false, Message = "La fecha del avance no puede ser menor a la fecha inicio de las actividades" }); } var respuesta = Existe(AvanceGestionCambio); if (!respuesta.IsSuccess) { db.AvanceGestionCambio.Add(AvanceGestionCambio); 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(AvanceGestionCambio AvanceGestionCambio) { Response response = new Response(); try { var actividadesGestionCambio = new ActividadesGestionCambio { IdActividadesGestionCambio = AvanceGestionCambio.IdActividadesGestionCambio, }; var respuestaActividades = await apiServicio.ObtenerElementoAsync <ActividadesGestionCambio>(actividadesGestionCambio, new Uri(WebApp.BaseAddress), "/api/ActividadesGestionCambio/ActividadesGestionCambioconIdActividad"); var actividades = JsonConvert.DeserializeObject <ActividadesGestionCambio>(respuestaActividades.Resultado.ToString()); var respuestaSuma = await apiServicio.ObtenerElementoAsync <ActividadesGestionCambio>(actividadesGestionCambio, new Uri(WebApp.BaseAddress), "/api/AvancesGestionCambio/AvanceGestionCambioSumaIndicadorReal"); var suma = JsonConvert.DeserializeObject <AvanceGestionCambioModel>(respuestaSuma.Resultado.ToString()); if ((suma.Suma + AvanceGestionCambio.Indicadorreal) <= actividades.Indicador) { response = await apiServicio.InsertarAsync(AvanceGestionCambio, new Uri(WebApp.BaseAddress), "/api/AvancesGestionCambio/InsertarAvanceGestionCambio"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), ExceptionTrace = null, Message = "Se ha creado un avance gestión de cambio", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "Avance gestión de cambio:", AvanceGestionCambio.IdAvanceGestionCambio), }); return(RedirectToAction("Index", new { IdActividadesGestionCambio = AvanceGestionCambio.IdActividadesGestionCambio })); } else { ViewData["Error"] = response.Message; return(View(AvanceGestionCambio)); } } else { string mensaje = "No se puede crear el avance de control cambio ya que el indicador de la actividad es " + actividades.Indicador + " y la suma del indicador real es de " + suma.Suma + " y al aumentarle " + AvanceGestionCambio.Indicadorreal + " sobrepasaría en " + ((suma.Suma + AvanceGestionCambio.Indicadorreal) - actividades.Indicador); ViewData["Error"] = mensaje; return(View(AvanceGestionCambio)); } } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Creando un avance gestión de cambio", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }