public ActionResult Post(bool IsNew, Detalle_Preferencia_BebidasModel varDetalle_Preferencia_Bebidas) { try { if (ModelState.IsValid) { if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IDetalle_Preferencia_BebidasApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var Detalle_Preferencia_BebidasInfo = new Detalle_Preferencia_Bebidas { Folio = varDetalle_Preferencia_Bebidas.Folio , Bebida = varDetalle_Preferencia_Bebidas.Bebida , Cantidad = varDetalle_Preferencia_Bebidas.Cantidad }; result = !IsNew? _IDetalle_Preferencia_BebidasApiConsumer.Update(Detalle_Preferencia_BebidasInfo, null, null).Resource.ToString() : _IDetalle_Preferencia_BebidasApiConsumer.Insert(Detalle_Preferencia_BebidasInfo, null, null).Resource.ToString(); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (ServiceException ex) { return(Json(false, JsonRequestBehavior.AllowGet)); } }
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, 44336); ViewBag.Permission = permission; var varDetalle_Preferencia_Bebidas = new Detalle_Preferencia_BebidasModel(); ViewBag.ObjectId = "44336"; 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_Preferencia_BebidasApiConsumer.SetAuthHeader(_tokenManager.Token); var Detalle_Preferencia_BebidasData = _IDetalle_Preferencia_BebidasApiConsumer.GetByKeyComplete(Id).Resource.Detalle_Preferencia_Bebidass[0]; if (Detalle_Preferencia_BebidasData == null) { return(HttpNotFound()); } varDetalle_Preferencia_Bebidas = new Detalle_Preferencia_BebidasModel { Folio = (int)Detalle_Preferencia_BebidasData.Folio , Bebida = Detalle_Preferencia_BebidasData.Bebida , BebidaDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Preferencia_BebidasData.Bebida), "Bebidas") ?? (string)Detalle_Preferencia_BebidasData.Bebida_Bebidas.Descripcion , Cantidad = Detalle_Preferencia_BebidasData.Cantidad , CantidadDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Preferencia_BebidasData.Cantidad), "Rango_Consumo_Bebidas") ?? (string)Detalle_Preferencia_BebidasData.Cantidad_Rango_Consumo_Bebidas.Descripcion }; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IBebidasApiConsumer.SetAuthHeader(_tokenManager.Token); var Bebidass_Bebida = _IBebidasApiConsumer.SelAll(true); if (Bebidass_Bebida != null && Bebidass_Bebida.Resource != null) { ViewBag.Bebidass_Bebida = Bebidass_Bebida.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem { Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Bebidas", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave) }).ToList(); } _IRango_Consumo_BebidasApiConsumer.SetAuthHeader(_tokenManager.Token); var Rango_Consumo_Bebidass_Cantidad = _IRango_Consumo_BebidasApiConsumer.SelAll(true); if (Rango_Consumo_Bebidass_Cantidad != null && Rango_Consumo_Bebidass_Cantidad.Resource != null) { ViewBag.Rango_Consumo_Bebidass_Cantidad = Rango_Consumo_Bebidass_Cantidad.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem { Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Rango_Consumo_Bebidas", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave) }).ToList(); } ViewBag.Consult = consult == 1; if (consult == 1) { ViewBag.Operation = "Consult"; } return(View(varDetalle_Preferencia_Bebidas)); }
public ActionResult AddDetalle_Preferencia_Bebidas(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, 44336); ViewBag.Permission = permission; if (!_tokenManager.GenerateToken()) { return(null); } _IDetalle_Preferencia_BebidasApiConsumer.SetAuthHeader(_tokenManager.Token); Detalle_Preferencia_BebidasModel varDetalle_Preferencia_Bebidas = new Detalle_Preferencia_BebidasModel(); if (id.ToString() != "0") { var Detalle_Preferencia_BebidassData = _IDetalle_Preferencia_BebidasApiConsumer.ListaSelAll(0, 1000, "Detalle_Preferencia_Bebidas.Folio=" + id, "").Resource.Detalle_Preferencia_Bebidass; if (Detalle_Preferencia_BebidassData != null && Detalle_Preferencia_BebidassData.Count > 0) { var Detalle_Preferencia_BebidasData = Detalle_Preferencia_BebidassData.First(); varDetalle_Preferencia_Bebidas = new Detalle_Preferencia_BebidasModel { Folio = Detalle_Preferencia_BebidasData.Folio , Bebida = Detalle_Preferencia_BebidasData.Bebida , BebidaDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Preferencia_BebidasData.Bebida), "Bebidas") ?? (string)Detalle_Preferencia_BebidasData.Bebida_Bebidas.Descripcion , Cantidad = Detalle_Preferencia_BebidasData.Cantidad , CantidadDescripcion = CultureHelper.GetTraduction(Convert.ToString(Detalle_Preferencia_BebidasData.Cantidad), "Rango_Consumo_Bebidas") ?? (string)Detalle_Preferencia_BebidasData.Cantidad_Rango_Consumo_Bebidas.Descripcion }; } } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _IBebidasApiConsumer.SetAuthHeader(_tokenManager.Token); var Bebidass_Bebida = _IBebidasApiConsumer.SelAll(true); if (Bebidass_Bebida != null && Bebidass_Bebida.Resource != null) { ViewBag.Bebidass_Bebida = Bebidass_Bebida.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem { Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Bebidas", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave) }).ToList(); } _IRango_Consumo_BebidasApiConsumer.SetAuthHeader(_tokenManager.Token); var Rango_Consumo_Bebidass_Cantidad = _IRango_Consumo_BebidasApiConsumer.SelAll(true); if (Rango_Consumo_Bebidass_Cantidad != null && Rango_Consumo_Bebidass_Cantidad.Resource != null) { ViewBag.Rango_Consumo_Bebidass_Cantidad = Rango_Consumo_Bebidass_Cantidad.Resource.Where(m => m.Descripcion != null).OrderBy(m => m.Descripcion).Select(m => new SelectListItem { Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Rango_Consumo_Bebidas", "Descripcion") ?? m.Descripcion.ToString(), Value = Convert.ToString(m.Clave) }).ToList(); } return(PartialView("AddDetalle_Preferencia_Bebidas", varDetalle_Preferencia_Bebidas)); }