Пример #1
0
 [HttpPost("DeleteByID")]                                                             //Xóa quận truyền vào IDDistrict
 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
             {
                 District district = new District();                                  //Khai báo biến Model District
                 district.Delete(id);                                                 //Delete data
                 return(Ok(new[] { "Xóa thành công" }));
             }
             else
             {
                 return(Ok(new[] { "Bạn Không có quyền" }));
             }
         }
         else
         {
             return(Ok(new[] { "Bạn cần đăng nhập" }));
         }
     }
     catch {
         return(Ok(new[] { "Error" }));
     }
 }
Пример #2
0
        public ActionResult DeleteDistrict(int Id)
        {
            int      Result = 0;
            District obj    = new District();

            Result = obj.Delete(Id);
            if (Result != Id)
            {
                obj.Msg = "District Deleted successfully";
            }
            else
            {
                obj.Msg = "District can not be Deleted";
            }
            obj.GetAllDistrict();
            return(View("DistrictMaster", obj));
        }