Refactored repository pattern for Add and Update methods so that they return their respective entity objects
This commit is contained in:
@ -37,14 +37,14 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<Alias>(apiurl + "/" + AliasId.ToString());
|
||||
}
|
||||
|
||||
public async Task AddAliasAsync(Alias alias)
|
||||
public async Task<Alias> AddAliasAsync(Alias alias)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, alias);
|
||||
return await http.PostJsonAsync<Alias>(apiurl, alias);
|
||||
}
|
||||
|
||||
public async Task UpdateAliasAsync(Alias alias)
|
||||
public async Task<Alias> UpdateAliasAsync(Alias alias)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + alias.AliasId.ToString(), alias);
|
||||
return await http.PutJsonAsync<Alias>(apiurl + "/" + alias.AliasId.ToString(), alias);
|
||||
}
|
||||
public async Task DeleteAliasAsync(int AliasId)
|
||||
{
|
||||
|
@ -10,9 +10,9 @@ namespace Oqtane.Services
|
||||
|
||||
Task<Alias> GetAliasAsync(int AliasId);
|
||||
|
||||
Task AddAliasAsync(Alias alias);
|
||||
Task<Alias> AddAliasAsync(Alias Alias);
|
||||
|
||||
Task UpdateAliasAsync(Alias alias);
|
||||
Task<Alias> UpdateAliasAsync(Alias Alias);
|
||||
|
||||
Task DeleteAliasAsync(int AliasId);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ namespace Oqtane.Services
|
||||
Task<List<Module>> GetModulesAsync(int PageId);
|
||||
Task<List<Module>> GetModulesAsync(int SiteId, string ModuleDefinitionName);
|
||||
Task<Module> GetModuleAsync(int ModuleId);
|
||||
Task AddModuleAsync(Module module);
|
||||
Task UpdateModuleAsync(Module module);
|
||||
Task<Module> AddModuleAsync(Module Module);
|
||||
Task<Module> UpdateModuleAsync(Module Module);
|
||||
Task DeleteModuleAsync(int ModuleId);
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ namespace Oqtane.Services
|
||||
public interface IPageModuleService
|
||||
{
|
||||
Task<List<PageModule>> GetPageModulesAsync();
|
||||
Task AddPageModuleAsync(PageModule pagemodule);
|
||||
Task UpdatePageModuleAsync(PageModule pagemodule);
|
||||
Task<PageModule> AddPageModuleAsync(PageModule PageModule);
|
||||
Task<PageModule> UpdatePageModuleAsync(PageModule PageModule);
|
||||
Task DeletePageModuleAsync(int PageModuleId);
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ namespace Oqtane.Services
|
||||
{
|
||||
Task<List<Page>> GetPagesAsync(int SiteId);
|
||||
Task<Page> GetPageAsync(int PageId);
|
||||
Task AddPageAsync(Page page);
|
||||
Task UpdatePageAsync(Page page);
|
||||
Task<Page> AddPageAsync(Page Page);
|
||||
Task<Page> UpdatePageAsync(Page Page);
|
||||
Task DeletePageAsync(int PageId);
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ namespace Oqtane.Services
|
||||
|
||||
Task<Site> GetSiteAsync(int SiteId);
|
||||
|
||||
Task AddSiteAsync(Site site);
|
||||
Task<Site> AddSiteAsync(Site Site);
|
||||
|
||||
Task UpdateSiteAsync(Site site);
|
||||
Task<Site> UpdateSiteAsync(Site Site);
|
||||
|
||||
Task DeleteSiteAsync(int SiteId);
|
||||
}
|
||||
|
@ -12,18 +12,18 @@ namespace Oqtane.Services
|
||||
|
||||
Task<User> GetUserAsync(string Username);
|
||||
|
||||
Task AddUserAsync(User user);
|
||||
Task<User> AddUserAsync(User User);
|
||||
|
||||
Task UpdateUserAsync(User user);
|
||||
Task<User> UpdateUserAsync(User User);
|
||||
|
||||
Task DeleteUserAsync(int UserId);
|
||||
|
||||
Task<User> GetCurrentUserAsync();
|
||||
|
||||
Task<User> LoginUserAsync(User user);
|
||||
Task<User> LoginUserAsync(User User);
|
||||
|
||||
Task LogoutUserAsync();
|
||||
|
||||
bool IsAuthorized(User user, string accesscontrollist);
|
||||
bool IsAuthorized(User User, string AccessControlList);
|
||||
}
|
||||
}
|
||||
|
@ -46,14 +46,14 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<Module>(apiurl + "/" + ModuleId.ToString());
|
||||
}
|
||||
|
||||
public async Task AddModuleAsync(Module module)
|
||||
public async Task<Module> AddModuleAsync(Module Module)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, module);
|
||||
return await http.PostJsonAsync<Module>(apiurl, Module);
|
||||
}
|
||||
|
||||
public async Task UpdateModuleAsync(Module module)
|
||||
public async Task<Module> UpdateModuleAsync(Module Module)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + module.ModuleId.ToString(), module);
|
||||
return await http.PutJsonAsync<Module>(apiurl + "/" + Module.ModuleId.ToString(), Module);
|
||||
}
|
||||
|
||||
public async Task DeleteModuleAsync(int ModuleId)
|
||||
|
@ -31,14 +31,14 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<List<PageModule>>(apiurl);
|
||||
}
|
||||
|
||||
public async Task AddPageModuleAsync(PageModule pagemodule)
|
||||
public async Task<PageModule> AddPageModuleAsync(PageModule PageModule)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, pagemodule);
|
||||
return await http.PostJsonAsync<PageModule>(apiurl, PageModule);
|
||||
}
|
||||
|
||||
public async Task UpdatePageModuleAsync(PageModule pagemodule)
|
||||
public async Task<PageModule> UpdatePageModuleAsync(PageModule PageModule)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + pagemodule.PageModuleId.ToString(), pagemodule);
|
||||
return await http.PutJsonAsync<PageModule>(apiurl + "/" + PageModule.PageModuleId.ToString(), PageModule);
|
||||
}
|
||||
|
||||
public async Task DeletePageModuleAsync(int PageModuleId)
|
||||
|
@ -37,14 +37,14 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString());
|
||||
}
|
||||
|
||||
public async Task AddPageAsync(Page page)
|
||||
public async Task<Page> AddPageAsync(Page Page)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, page);
|
||||
return await http.PostJsonAsync<Page>(apiurl, Page);
|
||||
}
|
||||
|
||||
public async Task UpdatePageAsync(Page page)
|
||||
public async Task<Page> UpdatePageAsync(Page Page)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + page.PageId.ToString(), page);
|
||||
return await http.PutJsonAsync<Page>(apiurl + "/" + Page.PageId.ToString(), Page);
|
||||
}
|
||||
public async Task DeletePageAsync(int PageId)
|
||||
{
|
||||
|
@ -37,14 +37,14 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<Site>(apiurl + "/" + SiteId.ToString());
|
||||
}
|
||||
|
||||
public async Task AddSiteAsync(Site site)
|
||||
public async Task<Site> AddSiteAsync(Site Site)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, site);
|
||||
return await http.PostJsonAsync<Site>(apiurl, Site);
|
||||
}
|
||||
|
||||
public async Task UpdateSiteAsync(Site site)
|
||||
public async Task<Site> UpdateSiteAsync(Site Site)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + site.SiteId.ToString(), site);
|
||||
return await http.PutJsonAsync<Site>(apiurl + "/" + Site.SiteId.ToString(), Site);
|
||||
}
|
||||
public async Task DeleteSiteAsync(int SiteId)
|
||||
{
|
||||
|
@ -43,14 +43,14 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<User>(apiurl + "/name/" + Username);
|
||||
}
|
||||
|
||||
public async Task AddUserAsync(User user)
|
||||
public async Task<User> AddUserAsync(User User)
|
||||
{
|
||||
await http.PostJsonAsync(apiurl, user);
|
||||
return await http.PostJsonAsync<User>(apiurl, User);
|
||||
}
|
||||
|
||||
public async Task UpdateUserAsync(User user)
|
||||
public async Task<User> UpdateUserAsync(User User)
|
||||
{
|
||||
await http.PutJsonAsync(apiurl + "/" + user.UserId.ToString(), user);
|
||||
return await http.PutJsonAsync<User>(apiurl + "/" + User.UserId.ToString(), User);
|
||||
}
|
||||
public async Task DeleteUserAsync(int UserId)
|
||||
{
|
||||
@ -62,9 +62,9 @@ namespace Oqtane.Services
|
||||
return await http.GetJsonAsync<User>(apiurl + "/current");
|
||||
}
|
||||
|
||||
public async Task<User> LoginUserAsync(User user)
|
||||
public async Task<User> LoginUserAsync(User User)
|
||||
{
|
||||
return await http.PostJsonAsync<User>(apiurl + "/login", user);
|
||||
return await http.PostJsonAsync<User>(apiurl + "/login", User);
|
||||
}
|
||||
|
||||
public async Task LogoutUserAsync()
|
||||
@ -74,23 +74,23 @@ namespace Oqtane.Services
|
||||
}
|
||||
|
||||
// ACLs are stored in the format "!rolename1;![userid1];rolename2;rolename3;[userid2];[userid3]" where "!" designates Deny permissions
|
||||
public bool IsAuthorized(User user, string accesscontrollist)
|
||||
public bool IsAuthorized(User User, string AccessControlList)
|
||||
{
|
||||
bool isAllowed = false;
|
||||
|
||||
if (user != null)
|
||||
if (User != null)
|
||||
{
|
||||
//super user always has full access
|
||||
isAllowed = user.IsSuperUser;
|
||||
isAllowed = User.IsSuperUser;
|
||||
}
|
||||
|
||||
if (!isAllowed)
|
||||
{
|
||||
if (accesscontrollist != null)
|
||||
if (AccessControlList != null)
|
||||
{
|
||||
foreach (string permission in accesscontrollist.Split(new[] { ';' }))
|
||||
foreach (string permission in AccessControlList.Split(new[] { ';' }))
|
||||
{
|
||||
bool? allowed = VerifyPermission(user, permission);
|
||||
bool? allowed = VerifyPermission(User, permission);
|
||||
if (allowed.HasValue)
|
||||
{
|
||||
isAllowed = allowed.Value;
|
||||
|
Reference in New Issue
Block a user