public bool GrantPermisstion(string EmployeeId, int roleId) { tbl_User_Role userRole = new tbl_User_Role(); userRole.EmployeeId = EmployeeId; userRole.Role_Id = roleId; userRole.CreateDate = DateTime.Now; var result = new UserDao().InsertUserRole(userRole); return(result); }
public bool InsertUserRole(tbl_User_Role userRole) { try { var checkRole = db.tbl_User_Role.FirstOrDefault(x => x.EmployeeId == userRole.EmployeeId && x.Role_Id == userRole.Role_Id); if (checkRole == null) { db.tbl_User_Role.Add(userRole); db.SaveChanges(); } return(true); } catch (Exception ex) { WriteLogError.Write("InsertUserRole", ex.ToString()); return(false); } }