namespace Common.Logic.Extensions.Http { using System; using System.Collections.Generic; public class HttpResponse { private Exception exception; private HttpResponse(Boolean succeeded) => this.Succeeded = succeeded; private HttpResponse(Dictionary errors) : this(false) => this.Errors = errors; public HttpResponse(Exception exception) : this(false) => this.exception = exception; public Boolean Succeeded { get; } public Exception Exception { get; } public Dictionary Errors { get; } public static implicit operator HttpResponse(Boolean succeeded) => new HttpResponse(succeeded); public static implicit operator HttpResponse(Dictionary errors) => new HttpResponse(errors); public static implicit operator HttpResponse(Exception exception) => new HttpResponse(exception); public static implicit operator Boolean(HttpResponse result) => result?.Succeeded ?? false; public static implicit operator Dictionary(HttpResponse result) => result?.Errors ?? new Dictionary(); } }