public ActionResult AddSpartan_User_Role(int rowIndex = 0, int functionMode = 0, string id = "0") { ViewBag.currentRowIndex = rowIndex; ViewBag.functionMode = functionMode; ViewBag.Consult = false; var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 101); ViewBag.Permission = permission; if (!_tokenManager.GenerateToken()) { return(null); } _ISpartan_User_RoleApiConsumer.SetAuthHeader(_tokenManager.Token); Spartan_User_RoleModel varSpartan_User_Role = new Spartan_User_RoleModel(); if (id.ToString() != "0") { var Spartan_User_RolesData = _ISpartan_User_RoleApiConsumer.ListaSelAll(0, 1000, "User_Role_Id=" + id, "").Resource.Spartan_User_Roles; if (Spartan_User_RolesData != null && Spartan_User_RolesData.Count > 0) { var Spartan_User_RoleData = Spartan_User_RolesData.First(); varSpartan_User_Role = new Spartan_User_RoleModel { User_Role_Id = Spartan_User_RoleData.User_Role_Id , Description = Spartan_User_RoleData.Description , Status = Spartan_User_RoleData.Status , StatusDescription = (string)Spartan_User_RoleData.Status_Spartan_User_Role_Status.Description }; } } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_User_Role_StatusApiConsumer.SetAuthHeader(_tokenManager.Token); var Spartan_User_Role_Statuss = _ISpartan_User_Role_StatusApiConsumer.SelAll(true); if (Spartan_User_Role_Statuss != null && Spartan_User_Role_Statuss.Resource != null) { ViewBag.Spartan_User_Role_Statuss = Spartan_User_Role_Statuss.Resource.Select(m => new SelectListItem { Text = m.Description.ToString(), Value = Convert.ToString(m.User_Role_Status_Id) }).ToList(); } return(PartialView("AddSpartan_User_Role", varSpartan_User_Role)); }
public ActionResult Post(bool IsNew, Spartan_User_RoleModel varSpartan_User_Role) { try { //if (ModelState.IsValid) //{ if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_User_RoleApiConsumer.SetAuthHeader(_tokenManager.Token); var result = ""; var Spartan_User_RoleInfo = new Spartane.Core.Domain.Spartan_User_Role.Spartan_User_Role { User_Role_Id = varSpartan_User_Role.User_Role_Id , Description = varSpartan_User_Role.Description , Status = varSpartan_User_Role.Status }; result = !IsNew? _ISpartan_User_RoleApiConsumer.Update(Spartan_User_RoleInfo, null, null).Resource.ToString() : _ISpartan_User_RoleApiConsumer.Insert(Spartan_User_RoleInfo, null, null).Resource.ToString(); Session["KeyValueInserted"] = result; if (result != "-1") { Roles.InsertUpdateObject(Convert.ToInt32(result), Spartan_User_RoleInfo.Description, "en-us"); Roles.InsertUpdateObject(Convert.ToInt32(result), Spartan_User_RoleInfo.Description, "es-es"); } 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) { var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 101); ViewBag.Permission = permission; var varSpartan_User_Role = new Spartan_User_RoleModel(); ViewBag.ObjectId = "101"; 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)); } _ISpartan_User_RoleApiConsumer.SetAuthHeader(_tokenManager.Token); var Spartan_User_RoleData = _ISpartan_User_RoleApiConsumer.GetByKeyComplete(Id).Resource.Spartan_User_Roles[0]; if (Spartan_User_RoleData == null) { return(HttpNotFound()); } varSpartan_User_Role = new Spartan_User_RoleModel { User_Role_Id = (int)Spartan_User_RoleData.User_Role_Id , Description = Spartan_User_RoleData.Description , Status = Spartan_User_RoleData.Status , StatusDescription = (string)Spartan_User_RoleData.Status_Spartan_User_Role_Status.Description }; } if (!_tokenManager.GenerateToken()) { return(Json(null, JsonRequestBehavior.AllowGet)); } _ISpartan_User_Role_StatusApiConsumer.SetAuthHeader(_tokenManager.Token); var Spartan_User_Role_Statuss = _ISpartan_User_Role_StatusApiConsumer.SelAll(true); if (Spartan_User_Role_Statuss != null && Spartan_User_Role_Statuss.Resource != null) { ViewBag.Spartan_User_Role_Statuss = Spartan_User_Role_Statuss.Resource.Select(m => new SelectListItem { Text = m.Description.ToString(), Value = Convert.ToString(m.User_Role_Status_Id) }).ToList(); } ViewBag.Consult = consult == 1; if (consult == 1) { ViewBag.Operation = "Consult"; } return(View(varSpartan_User_Role)); }