-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mattbarry/master
Refactor BaseResponse to use generic resource type
- Loading branch information
Showing
5 changed files
with
26 additions
and
31 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
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: 14 additions & 5 deletions
19
src/Supermarket.API/Domain/Services/Communication/BaseResponse.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 |
---|---|---|
@@ -1,14 +1,23 @@ | ||
namespace Supermarket.API.Domain.Services.Communication | ||
{ | ||
public abstract class BaseResponse | ||
public abstract class BaseResponse<T> | ||
{ | ||
public bool Success { get; protected set; } | ||
public string Message { get; protected set; } | ||
public bool Success { get; private set; } | ||
public string Message { get; private set; } | ||
public T Resource { get; private set; } | ||
|
||
public BaseResponse(bool success, string message) | ||
protected BaseResponse(T resource) | ||
{ | ||
Success = success; | ||
Success = true; | ||
Message = string.Empty; | ||
Resource = resource; | ||
} | ||
|
||
protected BaseResponse(string message) | ||
{ | ||
Success = false; | ||
Message = message; | ||
Resource = default; | ||
} | ||
} | ||
} |
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