API Result Structure & Web API
Standardized Response Models and Web API Architecture in AUA
Understanding Web API in AUA
API is a software implementation interface that allows other applications to interact with it, enabling HTTP protocol-based services for web browsers, mobile devices, and desktop applications.
In the last layer of the AUA framework, technologies like MVC, Rest WebAPI, gRPC, GraphQL, and JWT (JSON Web Token) can be implemented for secure access levels. Swagger is integrated for ease of use and testing, and all login/token requirements are fully pre-written and ready for your business development.
Web API Result (ResultModel)
Standardized output structure for all endpoints
In AUA, the output structure of all APIs is uniform, encapsulated within the ResultModel<TResult> class, which includes three core fields:
Returns true if no errors occurred, otherwise false.
Contains collection of error descriptions when exceptions happen.
Carries the actual payload (TResult data type).
Error Handling & ErrorVm Details
When an exception occurs, IsSuccess turns false. The ErrorVm contains fields such as ErrorMessage (shows the text of the error), ErrorIssuer (the reason or source), and ELogType (the type of error). The Errors list points to the precise line/origin, while full technical descriptions are safely handled within the framework.
3. Throwing Managed Client Exceptions (ClientException)
Throwing a ClientException immediately breaks execution flow safely and returns a structured ErrorVm message in the API result without exposing raw database exceptions.
public async Task ValidateStudentAsync(int studentId)
{
var student = await GetByIdAsync(studentId);
if (student == null)
{
throw new ClientException("Student record with specified ID does not exist.");
}
}
"If you think good architecture is expensive, try bad architecture."AUA Framework Philosophy