public async Task <ActionResult <LoggedInUserModel> > Register([FromBody] RegisterAccountModel account) { var newUser = new User() { Email = account.Email, UserName = account.Username, YearOfBirth = account.YearOfBirth }; var libraryId = _libraryService.Add(new LibraryDTO() { Name = newUser.Email + "_Library" }); newUser.LibraryId = libraryId; var creationResult = await _userManager.CreateAsync(newUser, account.Password); if (!creationResult.Succeeded) { return(null); } var user = await _userManager.FindByEmailAsync(account.Email); return(new LoggedInUserModel { UserId = user.Id, Username = account.Username, LibraryId = libraryId }); }
private static async Task GetBookData(ILibraryData libraryClient, ILibraryService libraryService) { try { var books = await GetBooksData(libraryClient); foreach (var book in books) { var bookmodel = new Book() { Id = book.Id, Name = book.Name, Publisher = book.Publisher, Country = book.Country, Released = Convert.ToDateTime(book.Released) }; libraryService.Add(bookmodel); } } catch (ApiException ex) { var content = ex.GetContentAs <Dictionary <String, String> >(); Console.WriteLine(ex.StatusCode); } }
public async Task <LibraryItem> AddLibraryItem(string dataSourceId, string bookId) { return(await _libraryService.Add(dataSourceId, bookId)); }