public async Task <Option <User> > AddNewUser(SpotifyConnectionDataDto spotifyConnectionData) { var jsonResponse = await GetUserInfo(spotifyConnectionData); if (jsonResponse == null) { return(Option.None <User>()); } if (string.IsNullOrEmpty((string)jsonResponse["id"])) { return(Option.None <User>()); } var newUser = new User { AccessToken = spotifyConnectionData.access_token, ExpirationTime = DateTime.Now.Add(TimeSpan.FromSeconds(spotifyConnectionData.expires_in)), RefreshToken = spotifyConnectionData.refresh_token, Scope = spotifyConnectionData.scope, TokenType = spotifyConnectionData.token_type, SpotifyId = (string)jsonResponse["id"] }; await _billboardDbContext.AddAsync(newUser); await _billboardDbContext.SaveChangesAsync(); return(Option.Some(newUser)); }
public async Task <IActionResult> Create([Bind("title,location,events,description")] BillboardDetails details, IFormFile image) { if (ModelState.IsValid) { var filePath = Path.Combine(_environment.WebRootPath, "UploadedImages", Path.GetFileName(image.FileName)); var fileName = Path.GetFileName(image.FileName); ViewBag.Files = Path.Combine(_environment.WebRootPath, "UploadedImages"); await image.CopyToAsync(new FileStream(filePath, FileMode.Create)); details.image = fileName; _context.Add(details); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(details)); }