public ActionResult Create(int Id = 0, int consult = 0) { int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0; var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 45190); ViewBag.Permission = permission; var varDetalle_Historico_JA = new Detalle_Historico_JAModel(); ViewBag.ObjectId = "45190"; ViewBag.Operation = "New"; ViewBag.IsNew = true; if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0")) { ViewBag.IsNew = false; ViewBag.Operation = "Update"; if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_Historico_JAApiConsumer.SetAuthHeader(_tokenManager.Token); var Detalle_Historico_JAData = _IDetalle_Historico_JAApiConsumer.GetByKeyComplete(Id).Resource.Detalle_Historico_JAs[0]; if (Detalle_Historico_JAData == null) { return(HttpNotFound()); } varDetalle_Historico_JA = new Detalle_Historico_JAModel { Clave = (int)Detalle_Historico_JAData.Clave , Fecha = (Detalle_Historico_JAData.Fecha == null ? string.Empty : Convert.ToDateTime(Detalle_Historico_JAData.Fecha).ToString(ConfigurationProperty.DateFormat)) , Hora = Detalle_Historico_JAData.Hora , Usuario = Detalle_Historico_JAData.Usuario , UsuarioName = CultureHelper.GetTraduction(Convert.ToString(Detalle_Historico_JAData.Usuario), "Spartan_User") ?? (string)Detalle_Historico_JAData.Usuario_Spartan_User.Name , Estatus = Detalle_Historico_JAData.Estatus }; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } ViewBag.Consult = consult == 1; if (consult == 1) { ViewBag.Operation = "Consult"; } return(View(varDetalle_Historico_JA)); }
public ActionResult AddDetalle_Historico_JA(int rowIndex = 0, int functionMode = 0, int id = 0) { int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0; ViewBag.currentRowIndex = rowIndex; ViewBag.functionMode = functionMode; ViewBag.Consult = false; var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 45190); ViewBag.Permission = permission; if (!_tokenManager.GenerateToken()) { return(null); } _IDetalle_Historico_JAApiConsumer.SetAuthHeader(_tokenManager.Token); Detalle_Historico_JAModel varDetalle_Historico_JA = new Detalle_Historico_JAModel(); if (id.ToString() != "0") { var Detalle_Historico_JAsData = _IDetalle_Historico_JAApiConsumer.ListaSelAll(0, 1000, "Detalle_Historico_JA.Clave=" + id, "").Resource.Detalle_Historico_JAs; if (Detalle_Historico_JAsData != null && Detalle_Historico_JAsData.Count > 0) { var Detalle_Historico_JAData = Detalle_Historico_JAsData.First(); varDetalle_Historico_JA = new Detalle_Historico_JAModel { Clave = Detalle_Historico_JAData.Clave , Fecha = (Detalle_Historico_JAData.Fecha == null ? string.Empty : Convert.ToDateTime(Detalle_Historico_JAData.Fecha).ToString(ConfigurationProperty.DateFormat)) , Hora = Detalle_Historico_JAData.Hora , Usuario = Detalle_Historico_JAData.Usuario , UsuarioName = CultureHelper.GetTraduction(Convert.ToString(Detalle_Historico_JAData.Usuario), "Spartan_User") ?? (string)Detalle_Historico_JAData.Usuario_Spartan_User.Name , Estatus = Detalle_Historico_JAData.Estatus }; } } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } return(PartialView("AddDetalle_Historico_JA", varDetalle_Historico_JA)); }
public ActionResult Post(bool IsNew, Detalle_Historico_JAModel varDetalle_Historico_JA) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_Historico_JAApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var Detalle_Historico_JAInfo = new Detalle_Historico_JA { Clave = varDetalle_Historico_JA.Clave , Fecha = (!String.IsNullOrEmpty(varDetalle_Historico_JA.Fecha)) ? DateTime.ParseExact(varDetalle_Historico_JA.Fecha, ConfigurationProperty.DateFormat, CultureInfo.InvariantCulture as IFormatProvider) : (DateTime?)null , Hora = varDetalle_Historico_JA.Hora , Usuario = varDetalle_Historico_JA.Usuario , Estatus = varDetalle_Historico_JA.Estatus }; result = !IsNew? _IDetalle_Historico_JAApiConsumer.Update(Detalle_Historico_JAInfo, null, null).Resource.ToString() : _IDetalle_Historico_JAApiConsumer.Insert(Detalle_Historico_JAInfo, null, null).Resource.ToString(); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }