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, 45219); ViewBag.Permission = permission; var varDetalle_de_Referencia = new Detalle_de_ReferenciaModel(); ViewBag.ObjectId = "45219"; 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_de_ReferenciaApiConsumer.SetAuthHeader(_tokenManager.Token); var Detalle_de_ReferenciaData = _IDetalle_de_ReferenciaApiConsumer.GetByKeyComplete(Id).Resource.Detalle_de_Referencias[0]; if (Detalle_de_ReferenciaData == null) { return(HttpNotFound()); } varDetalle_de_Referencia = new Detalle_de_ReferenciaModel { Clave = (int)Detalle_de_ReferenciaData.Clave , Punto_de_Referencia = Detalle_de_ReferenciaData.Punto_de_Referencia , Descripcion = Detalle_de_ReferenciaData.Descripcion , Distancia = Detalle_de_ReferenciaData.Distancia }; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } ViewBag.Consult = consult == 1; if (consult == 1) { ViewBag.Operation = "Consult"; } return(View(varDetalle_de_Referencia)); }
public ActionResult AddDetalle_de_Referencia(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, 45219); ViewBag.Permission = permission; if (!_tokenManager.GenerateToken()) { return(null); } _IDetalle_de_ReferenciaApiConsumer.SetAuthHeader(_tokenManager.Token); Detalle_de_ReferenciaModel varDetalle_de_Referencia = new Detalle_de_ReferenciaModel(); if (id.ToString() != "0") { var Detalle_de_ReferenciasData = _IDetalle_de_ReferenciaApiConsumer.ListaSelAll(0, 1000, "Detalle_de_Referencia.Clave=" + id, "").Resource.Detalle_de_Referencias; if (Detalle_de_ReferenciasData != null && Detalle_de_ReferenciasData.Count > 0) { var Detalle_de_ReferenciaData = Detalle_de_ReferenciasData.First(); varDetalle_de_Referencia = new Detalle_de_ReferenciaModel { Clave = Detalle_de_ReferenciaData.Clave , Punto_de_Referencia = Detalle_de_ReferenciaData.Punto_de_Referencia , Descripcion = Detalle_de_ReferenciaData.Descripcion , Distancia = Detalle_de_ReferenciaData.Distancia }; } } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } return(PartialView("AddDetalle_de_Referencia", varDetalle_de_Referencia)); }
public ActionResult Post(bool IsNew, Detalle_de_ReferenciaModel varDetalle_de_Referencia) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_de_ReferenciaApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var Detalle_de_ReferenciaInfo = new Detalle_de_Referencia { Clave = varDetalle_de_Referencia.Clave , Punto_de_Referencia = varDetalle_de_Referencia.Punto_de_Referencia , Descripcion = varDetalle_de_Referencia.Descripcion , Distancia = varDetalle_de_Referencia.Distancia }; result = !IsNew? _IDetalle_de_ReferenciaApiConsumer.Update(Detalle_de_ReferenciaInfo, null, null).Resource.ToString() : _IDetalle_de_ReferenciaApiConsumer.Insert(Detalle_de_ReferenciaInfo, null, null).Resource.ToString(); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }