Beispiel #1
0
 [HttpPost("DeleteByID")]                                                                 //Xóa loại tài khoản
 public IActionResult DeleteByID(string id)
 {
     try{
         var           identity = HttpContext.User.Identity as ClaimsIdentity;            //khai báo biến danh tính của token
         IList <Claim> claim    = identity.Claims.ToList();                               //Danh sách các biến trong identity
         string        Email    = claim[1].Value;                                         //Email của token
         User          infoUser = new User();                                             //Khai bao biến thông tin người dùng
         if (infoUser.kiemtrathoigianlogin(DateTime.Parse(claim[0].Value)) == true)       //kiểm tra thời gian đăng nhập còn không
         {
             if (infoUser.checkAdmin(Email) == true)                                      //Kiểm tra có phải admin không
             {
                 UserType userType = new UserType();                                      //Khai báo biến Model Usertype
                 userType.Delete(id);                                                     //Xóa data
                 return(Ok(new[] { "Xóa thành công" }));
             }
             return(Ok("Bạn không có quyền"));
         }
         else
         {
             return(Ok(new[] { "Bạn cần đăng nhập" }));
         }
     }
     catch {
         return(Ok(new[] { "Error" }));
     }
 }
 public ActionResult Delete(Guid id, UserType ut)
 {
     try
     {
         // TODO: Add delete logic here
         ut.Delete();
         return(RedirectToAction("Index"));
     }
     catch { return(View(ut)); }
 }
Beispiel #3
0
        public bool Delete()
        {
            UserType userType = UserType.GetUserType(this.m_parentID);

            if (userType == null)
            {
                return(false);
            }
            userType.Delete();
            return(true);
        }
Beispiel #4
0
        public void Delete()
        {
            UserTypeList userTypes = new UserTypeList();

            userTypes.Load();

            UserType userTypeType = userTypes.FirstOrDefault(u => u.Description == "TestUpdate");

            int rowsAffected = userTypeType.Delete();

            Assert.IsTrue(rowsAffected == 1);
        }
Beispiel #5
0
        protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string ID = gridView.DataKeys[e.RowIndex].Value.ToString();

            try
            {
                userTypeManage.Delete(ID);
                string keyname = gridView.Rows[e.RowIndex].Cells[0].Text;
                LogHelp.AddUserLog(CurrentUser.UserName, CurrentUser.UserType, string.Format("删除用户类别:【{0}】", keyname), this);
                gridView.OnBind();
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                if (ex.Number == 547)
                {
                    YSWL.Common.MessageBox.ShowSuccessTip(this, Resources.Site.ErrorCannotDeleteUser);
                }
            }
        }