using System.Collections.Generic; using System.Linq; using API.Data; using API.Entities; using Kavita.Common; namespace API.Helpers.Builders; public class AppUserBuilder : IEntityBuilder { private readonly AppUser _appUser; public AppUser Build() => _appUser; public AppUserBuilder(string username, string email, SiteTheme? theme = null) { _appUser = new AppUser() { UserName = username, Email = email, ApiKey = HashUtil.ApiKey(), UserPreferences = new AppUserPreferences { Theme = theme ?? Seed.DefaultThemes.First() }, ReadingLists = new List(), Bookmarks = new List(), Libraries = new List(), Ratings = new List(), Progresses = new List(), Devices = new List(), Id = 0, DashboardStreams = new List() }; foreach (var s in Seed.DefaultStreams) { _appUser.DashboardStreams.Add(s); } } public AppUserBuilder WithLibrary(Library library) { _appUser.Libraries.Add(library); return this; } public AppUserBuilder WithLocale(string locale) { _appUser.UserPreferences.Locale = locale; return this; } }