Exemple #1
0
    public string ToString(string?format, IFormatProvider?provider)
    {
        if (string.IsNullOrWhiteSpace(format))
        {
            return(DefaultName());
        }
        var culture = provider is null ? CultureInfo.CurrentCulture : (CultureInfo)provider;

        return(NameModel.FromUserModel(this) !.ToString(format, culture));
    }
Exemple #2
0
    public async Task <IEnumerable <NameModel> > GetNamesAsync()
    {
        var users = await GetAsync();

        List <NameModel> ret = new();

        foreach (var user in users)
        {
            var name = NameModel.FromUserModel(user) !;
            ret.Add(name);
        }
        return(ret);
    }
Exemple #3
0
    public static async Task <IResult> GetName(string email, IUserService userService)
    {
        if (string.IsNullOrWhiteSpace(email))
        {
            return(Results.BadRequest(new ApiError(string.Format(Strings.Invalid, "email"))));
        }
        var user = await userService.ReadAsync(email);

        if (user is null)
        {
            return(Results.BadRequest(new ApiError(string.Format(Strings.ItemNotFound, "user", "email", email))));
        }
        return(Results.Ok(NameModel.FromUserModel(user)));
    }