1
Answer

restrict specific data to delete or edit by user

i have table name of Role
i have two columns name RoleID and RoleName,
 
and it contains data like below,
1. Admin 
2. User
3. Employee
4. Etc. 
 
now in MVC view i have bind all the data into table view and allow EDIT and DELETE functionality,
 
but i dont want to allow user to delete or edit first two data(1. Admin, 2. User) from the database.
 
do anyone have any idea about this..
thanks in advance. 
Answers (1)
0
Dharmraj Thakur

Dharmraj Thakur

NA 4.1k 61.7k 7y
Hi Dheeraj,
 
Just Run a query of checking user's permission before delete like this...

I assuming that you have a mapping table of UserPermissions
  1. IF EXISTS(select count(*) from UserRoleMapping where UserID = 1 and RoleID = 1 and PermissionID = 1)  
  2. BEGIN  
  3.     --delete the data  
  4. END  
  5. ELSE  
  6. BEGIN  
  7.     --you have no rights to delete the data  
  8. END 
 Thats it...