public ActionResult Edit(int?id) { try { if (id == null || id == 0) { TempData["typemessage"] = "2"; TempData["message"] = "Verifique sus datos."; return(RedirectToAction("Index")); } Token.SaveToken(); PesajeGanadoModels oPesaje = new PesajeGanadoModels(); _PesajeGanado_Datos oDatosPesaje = new _PesajeGanado_Datos(); oPesaje = oDatosPesaje.PesajeGanado_spCIDDB_get_pesajeGanadoXID(id.Value, conexion); if (oPesaje.Respuesta.Success) { CargarListas(); return(View(oPesaje)); } else { TempData["typemessage"] = "2"; TempData["message"] = oPesaje.Respuesta.Mensaje; return(RedirectToAction("Index")); } } catch (Exception) { TempData["typemessage"] = "2"; TempData["message"] = "No se puede cargar la vista."; return(RedirectToAction("Index")); } }
public ActionResult Create(PesajeGanadoModels oPesaje) { try { if (Token.IsTokenValid()) { if (ModelState.IsValid) { _PesajeGanado_Datos oDatosPesaje = new _PesajeGanado_Datos(); string usuario = User.Identity.Name; RespuestaAjax respuesta = oDatosPesaje.PesajeGanado_spCIDDB_ac(oPesaje, 1, usuario, conexion); TempData["message"] = respuesta.Mensaje; if (respuesta.Success) { TempData["typemessage"] = "1"; Token.ResetToken(); return(RedirectToAction("Index")); } else { TempData["typemessage"] = "2"; CargarListas(); return(View(oPesaje)); } } else { CargarListas(); return(View(oPesaje)); } } else { return(RedirectToAction("Index")); } } catch { TempData["typemessage"] = "2"; TempData["message"] = "Ocurrio un error al intentar guardar los datos. Contacte a soporte técnico."; return(RedirectToAction("Index")); } }