Skip to content

EasyMicroservices/ServiceContracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ServiceContracts

Contracts between services

Install packages:

NuGet

ServiceContract lets you manage your service responses more quickly.

image

Easy return:

public class MyController : ControllerBase
{
    //...
    
        [HttpPost]
        public async Task<MessageContract<long>> Add(CreateFaqRequestContract request)
        {
            //Do stuff
            return 1452;
        }
}

Easy cast:

public class MyController : ControllerBase
{
    //...
    
        [HttpPost]
        public async Task<MessageContract<long>> Add(CreateFaqRequestContract request)
        {
            MessageContract<string> serviceResult = //service stuff;
            if (!serviceResult)
                return serviceResult.ToContract<long>();
            //Do stuff
            return 1452;
        }
}

Easy convert:

public class MyController : ControllerBase
{
    //...
    
        [HttpPost]
        public Task<MessageContract<long>> Add(CreateFaqRequestContract request)
        {
            Task<MessageContract<string>> serviceResult = //service stuff;
            return serviceResult.ToContract(x => long.Parse(x));
        }
}

Easy error:

public class MyController : ControllerBase
{
    //...
    
        [HttpPost]
        public async Task<MessageContract<long>> Add(CreateFaqRequestContract request)
        {
            return (FailedReasonType.NotFound, "Service result not found!");
        }
}

Releases

No releases published

Packages

No packages published

Languages