protected void btnDelete_Click(object sender, EventArgs e) { this.ChkAdminLevel("user_group", DTEnums.ActionEnum.Delete.ToString()); int num1 = 0; int num2 = 0; user_groups userGroups = new user_groups(); for (int index = 0; index < this.rptList.Items.Count; ++index) { int int32 = Convert.ToInt32(((HiddenField)this.rptList.Items[index].FindControl("hidId")).Value); if (((CheckBox)this.rptList.Items[index].FindControl("chkId")).Checked) { if (userGroups.Delete(int32)) { ++num1; } else { ++num2; } } } this.AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除用户组成功" + (object)num1 + "条,失败" + (object)num2 + "条"); this.JscriptMsg("删除成功" + (object)num1 + "条,失败" + (object)num2 + "条!", Utils.CombUrlTxt("group_list.aspx", "keywords={0}", this.txtKeywords.Text.Trim())); }
public HttpResponseMessage newGroup(string _group_name) { string group_uid = Guid.NewGuid().ToString(); group n_group = new group() { group_name = _group_name, group_uid = group_uid }; dbContext.groups.Add(n_group); user_groups n_user_groups = new user_groups() { group_uid = group_uid, user_uid = User.Identity.GetUserId(), user_group_PK = Guid.NewGuid().ToString() }; dbContext.user_groups.Add(n_user_groups); try { dbContext.SaveChanges(); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Database could not be saved")); } var returnObject = new { group_name = n_group.group_name, group_uid = n_group.group_uid }; // need to do this since group has database fields can't serialize return(Request.CreateResponse(HttpStatusCode.OK, returnObject)); }
public HttpResponseMessage addGroup(string access_code) { string user_uid = User.Identity.GetUserId(); group _group = dbContext.groups.Where(e => e.access_code == access_code).FirstOrDefault(); if (_group == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } user_groups n_users_groups = new user_groups() { group_uid = _group.group_uid, user_uid = User.Identity.GetUserId(), user_group_PK = Guid.NewGuid().ToString() }; try { dbContext.user_groups.Add(n_users_groups); dbContext.SaveChanges(); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Database could not be saved")); } return(Request.CreateResponse(HttpStatusCode.OK, n_users_groups.user_group_PK)); }
private void TreeBind(string strWhere) { DataTable table = new user_groups().GetList(0, strWhere, "grade asc,id asc").Tables[0]; this.cblGroupId.Items.Clear(); foreach (DataRow row in (InternalDataCollectionBase)table.Rows) { this.cblGroupId.Items.Add(new ListItem(row["title"].ToString(), row["id"].ToString())); } }
public async Task <IHttpActionResult> Register(RegisterBindingModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var user = new ApplicationUser() { UserName = model.Name, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return(GetErrorResult(result)); } using (groceryappdbEntities dbContext = new groceryappdbEntities()) { user n_user = new user() { user_name = user.UserName, user_uid = user.Id }; dbContext.users.Add(n_user); dbContext.SaveChanges(); string group_uid = Guid.NewGuid().ToString(); group n_group = new group() { group_name = "My Group", group_uid = group_uid, access_code = Helpers.GetRandomString(5) }; dbContext.groups.Add(n_group); user_groups n_user_groups = new user_groups() { group_uid = group_uid, user_uid = user.Id, user_group_PK = Guid.NewGuid().ToString() }; dbContext.user_groups.Add(n_user_groups); dbContext.SaveChanges(); } return(Ok()); }
//GET: groups/deleteUser/5 Show the unsubscription confirmation for palyer subcription with subscription id 5 public ActionResult deleteUser(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } user_groups r_p = db.user_groups.Where(a => a.ID == id).Include(a => a.user).Include(a => a.group).FirstOrDefault(); if (r_p == null) { return(HttpNotFound()); } return(View(r_p)); }
//GET: groups/detailsGroup/5 Show the unsubscription confirmation for palyer subcription with subscription id 5 public ActionResult detailsUser(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } user_groups r_p = db.user_groups.Where(a => a.ID == id).Include(a => a.user).Include(a => a.group).FirstOrDefault(); if (r_p == null) { //TODO : define styled error response through logging return(HttpNotFound()); } return(View(r_p)); }
public void _delete_accesslevel(int id) { user_groups level = ActiveRecordBase <user_groups> .Find(id); Flash["error"] = "At the moment no one has rights to delete a group but the system."; if (id == 999999) { try { ActiveRecordMediator <user_groups> .Delete(level); } catch (Exception ex) { Flash["error"] = ex.Message; } } RedirectToAction("list"); }
public void _update_accesslevel([ARDataBind("accesslevel", Validate = true, AutoLoad = AutoLoadBehavior.NewInstanceIfInvalidKey)] user_groups accesslevel) { try { ActiveRecordMediator <user_groups> .Save(accesslevel); } catch (Exception ex) { Flash["error"] = ex.Message; Flash["accesslevel"] = accesslevel; if (accesslevel.id > 0) { RedirectToAction("_edit_accesslevel", new string[] { "id", accesslevel.id.ToString() }); } else { RedirectToAction("_new_accesslevel"); } return; } RedirectToAction("list"); }