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)); }
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); }
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))); }