-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
877 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/DotNetNuke.PowerBI/Data/Bookmarks/BookmarksRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using DotNetNuke.Framework; | ||
using DotNetNuke.PowerBI.Data.Bookmarks.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using DotNetNuke.Common; | ||
using DotNetNuke.Data; | ||
using DotNetNuke.PowerBI.Services; | ||
|
||
namespace DotNetNuke.PowerBI.Data.Bookmarks | ||
{ | ||
public class BookmarksRepository : ServiceLocator<IBookmarksRepository, BookmarksRepository>, IBookmarksRepository | ||
{ | ||
public bool DeleteBookmark(int bookmarkId) | ||
{ | ||
Requires.NotNegative("portalId", bookmarkId); | ||
using (var ctx = DataContext.Instance()) | ||
{ | ||
var repo = ctx.GetRepository<Bookmark>(); | ||
var bookmark = repo.GetById(bookmarkId); | ||
repo.Delete(bookmark); | ||
return true; | ||
} | ||
} | ||
|
||
public List<Bookmark> GetBookmarks(string reportId, int currentPortalId) | ||
{ | ||
Requires.NotNull(reportId); | ||
using (var ctx = DataContext.Instance()) | ||
{ | ||
var repo = ctx.GetRepository<Bookmark>(); | ||
var bookmarks = repo.Get(currentPortalId).Where(bookmark => bookmark.ReportId == reportId).ToList(); | ||
return bookmarks; | ||
} | ||
} | ||
|
||
public List<Bookmark> GetBookmarksByUser(int portalId, string reportId, int userId) | ||
{ | ||
Requires.NotNegative("portalId", portalId); | ||
Requires.NotNull(reportId); | ||
Requires.NotNull(userId); | ||
|
||
using (var ctx = DataContext.Instance()) | ||
{ | ||
var repo = ctx.GetRepository<Bookmark>(); | ||
var bookmarks = repo.Get(portalId).Where(bookmark => bookmark.CreatedBy == userId && bookmark.ReportId == reportId).ToList(); | ||
return bookmarks; | ||
} | ||
} | ||
|
||
public int SaveBookmark(Bookmark bookmark) | ||
{ | ||
Requires.NotNull(bookmark); | ||
|
||
bookmark.CreatedOn = DateTime.Now; | ||
bookmark.CreatedBy = Components.Common.CurrentUser.UserID; | ||
|
||
using (var ctx = DataContext.Instance()) | ||
{ | ||
var repo = ctx.GetRepository<Bookmark>(); | ||
repo.Insert(bookmark); | ||
|
||
return bookmark.Id; | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
protected override Func<IBookmarksRepository> GetFactory() | ||
{ | ||
return () => new BookmarksRepository(); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/DotNetNuke.PowerBI/Data/Bookmarks/IBookmarksRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using DotNetNuke.PowerBI.Data.Bookmarks.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
|
||
|
||
namespace DotNetNuke.PowerBI.Data.Bookmarks | ||
{ | ||
public interface IBookmarksRepository | ||
{ | ||
List<Bookmark> GetBookmarks(string reportId, int currentPortalId); | ||
List<Bookmark> GetBookmarksByUser(int portalId, string reportId,int userId); | ||
int SaveBookmark(Bookmark bookmark); | ||
bool DeleteBookmark(int bookmarkId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using DotNetNuke.ComponentModel.DataAnnotations; | ||
using System.Web.Caching; | ||
using DotNetNuke.PowerBI.Services; | ||
|
||
namespace DotNetNuke.PowerBI.Data.Bookmarks.Models | ||
{ | ||
[TableName("PBI_Bookmarks")] | ||
//setup the primary key for table | ||
[PrimaryKey("Id", AutoIncrement = true)] | ||
//scope the objects to the ModuleId of a module on a page (or copy of a module on a page) | ||
[Scope("PortalId")] | ||
public class Bookmark | ||
{ | ||
public Bookmark() | ||
{ | ||
} | ||
public Bookmark(BookmarksController.BookmarkViewModel bookmarkViewModel, int userId, int portalId) | ||
{ | ||
Name = bookmarkViewModel.name; | ||
DisplayName = bookmarkViewModel.displayName; | ||
State = bookmarkViewModel.state; | ||
ReportId = bookmarkViewModel.reportId; | ||
PortalId = portalId; | ||
} | ||
public int Id { get; set; } | ||
public int PortalId{get; set; } | ||
public string ReportId { get; set; } | ||
public string DisplayName { get; set; } | ||
public string Name { get; set; } | ||
public string State { get; set; } | ||
public DateTime CreatedOn { get; set; } | ||
public int CreatedBy { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/DotNetNuke.PowerBI/Providers/DataProviders/SqlDataProvider/01.00.07.SqlDataProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
IF (NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'PBI_Bookmarks')) | ||
BEGIN | ||
CREATE TABLE {databaseOwner}[{objectQualifier}PBI_Bookmarks]( | ||
[Id] [int] IDENTITY(1,1) NOT NULL, | ||
[PortalId] [int] NOT NULL, | ||
[ReportId] [nvarchar](100) NOT NULL, | ||
[DisplayName] [nvarchar](100) NOT NULL, | ||
[Name] [nvarchar](100) NOT NULL, | ||
[State] [nvarchar](max) NOT NULL, | ||
[CreatedOn] [date] NOT NULL, | ||
[CreatedBy] [int] NOT NULL | ||
CONSTRAINT [PK_PBI_Bookmarks] PRIMARY KEY CLUSTERED | ||
( | ||
[Id] ASC | ||
) | ||
) | ||
END | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.