public static void InsertOrUpdateOperationToRole(int userId, int functionId, Operations operation, string role, string maNhaThuoc = "") { var uow = new UnitOfWork(); var row = uow.OperationsToRolesRepository.GetOperationToRolesByUser(userId, functionId, role, maNhaThuoc); if (row != null) { row.Operations = operation; uow.OperationsToRolesRepository.Update(row); uow.Save(); } else { row = new OperationsToRoles() { UserId = userId, FunctionId = functionId, Operations = operation, RoleName = role, MaNhaThuoc = maNhaThuoc }; uow.OperationsToRolesRepository.Insert(row); uow.Save(); } }
public static void MapOperationToRole(int resourceId, Operations operation, string role) { UnitOfWork uow = new UnitOfWork(); OperationsToRoles o2r = new OperationsToRoles() { ResourceId = resourceId, Operations = operation, RoleName = role }; uow.OperationsToRolesRepository.Insert(o2r); uow.Save(); }