Generic Response for .net projects
Install-Package Ceyhan.GenericResponse -Version 1.0.0
using GenericResponse;
Return success
public static GenericResponse<User> FakeService(User user)
{
return new GenericResponse<User>(user);
}
Return fail
public static GenericResponse<User> FakeService(User user)
{
return new GenericResponse<User>("Something happend");
}
Check methods response
var userRegisterResponse = RegisterNewUser(user);
if (userRegisterResponse.Success)
{
Console.WriteLine($"User {userRegisterResponse.GenericModel.Name} is successfully registered");
}
else
{
Console.WriteLine($"Log error - {userRegisterResponse.Message}");
}
For interfaces;
public interface IUserService
{
Task<GenericResponse<User>> Logout(string token);
}
- Add more examples
- Publish as a nuget pack
This project is licensed under MIT license.