Skip to content

Commit

Permalink
Merge pull request #5 from djsleurink/module/extensibleServices
Browse files Browse the repository at this point in the history
Added IRepositoryService defining a template for a basic service implementation to make it easyer to add services
  • Loading branch information
rijwanansari authored Apr 28, 2024
2 parents d344b7e + df71882 commit a79c295
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
18 changes: 18 additions & 0 deletions Application/Common/Interface/IRepositoryService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Application.Common.Model;
using Application.Master.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.Common.Interface
{
public interface IRepositoryService<T> where T : class
{
Task<ResponseModel> GetAsync();
Task<ResponseModel> GetByIdAsync(int Id);
Task<ResponseModel> UpsertAsync(T modelToUpdate);
Task<ResponseModel> DeleteAsync(int Id);
}
}
23 changes: 12 additions & 11 deletions Application/Master/AppSettingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ public async Task<ResponseModel> DeleteAsync(int Id)
}
#endregion

#region Queries
public async Task<ResponseModel> GetAppSettingsAsync()
#region Queries

public async Task<ResponseModel> GetAsync()
{
try
{
Expand All @@ -86,13 +87,13 @@ public async Task<ResponseModel> GetAppSettingsAsync()
}
catch (Exception ex)
{
Log(nameof(GetAppSettingsAsync), ex.Message);
Log(nameof(GetAsync), ex.Message);
logger?.LogError(ex.ToString());
return ResponseModel.FailureResponse(GlobalDeclaration._internalServerError);
}
}
public async Task<ResponseModel> GetAppSettingByIdAsync(int Id)
}
}

public async Task<ResponseModel> GetByIdAsync(int Id)
{
try
{
Expand All @@ -107,12 +108,11 @@ public async Task<ResponseModel> GetAppSettingByIdAsync(int Id)
}
catch (Exception ex)
{
Log(nameof(DeleteAsync), ex.Message);
Log(nameof(GetByIdAsync), ex.Message);
logger?.LogError(ex.ToString());
return ResponseModel.FailureResponse(GlobalDeclaration._internalServerError);
}
}
}

#endregion

#endregion
Expand All @@ -121,7 +121,8 @@ public async Task<ResponseModel> GetAppSettingByIdAsync(int Id)
private void Log(string method, string msg)
{
errorMessageLog.LogError("Application", "AppSettingService", method, msg);
}
}

#endregion
}
}
9 changes: 3 additions & 6 deletions Application/Master/IAppSettingService.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using Application.Common.Model;
using Application.Common.Interface;
using Application.Common.Model;
using Application.Master.Dto;
using Domain.Master;

namespace Application.Master
{
public interface IAppSettingService
public interface IAppSettingService : IRepositoryService<AppSettingVm>
{
Task<ResponseModel> GetAppSettingsAsync();
Task<ResponseModel> GetAppSettingByIdAsync(int Id);
Task<ResponseModel> UpsertAsync(AppSettingVm appSetting);
Task<ResponseModel> DeleteAsync(int Id);
}
}
2 changes: 1 addition & 1 deletion WebApp/Pages/Master/AppSetting.razor
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ else
{
try
{
var response = await appSettingService.GetAppSettingsAsync();
var response = await appSettingService.GetAsync();
if (response.Success)
appSettingVmList = response.Output;
else
Expand Down

0 comments on commit a79c295

Please sign in to comment.