public ActionResult Create(int bandId) { BandSongSample s = new BandSongSample(); s.BandId = bandId; return(View(s)); }
public async Task <ActionResult> Create(Band band) { Band addBand = new Band(); addBand.City = band.City; addBand.State = band.State; addBand.Address = band.Address; addBand.Name = band.Name; addBand.UserId = User.FindFirstValue(ClaimTypes.NameIdentifier); addBand.Description = band.Description; addBand.Test = band.Test; var result = await client.GetStringAsync($"https://maps.googleapis.com/maps/api/geocode/json?address={addBand.Address}+{addBand.City}+{addBand.State}&key={GoogleMapsApiKey.Token}"); var data = JsonConvert.DeserializeObject <JObject>(result); double lat = (double)data["results"][0]["geometry"]["location"]["lat"]; double lon = (double)data["results"][0]["geometry"]["location"]["lng"]; addBand.Latitude = lat; addBand.Longitude = lon; addBand.GenreId = band.GenreId; _context.Bands.Add(addBand); _context.SaveChanges(); try { //return RedirectToAction("Create", "BandSongSample"); //return View($"BandSongSample/Create?bandId={addBand.BandId}"); if (addBand.Test) { return(RedirectToAction("Create", "BandRoadieTest", new { bandId = addBand.BandId })); } else { BandSongSample sample = new BandSongSample(); sample.BandId = addBand.BandId; return(View("../BandSongSample/Create", sample)); } } catch { return(View()); } }
public async Task <IActionResult> Upload(List <IFormFile> files, int bandId) { var id = User.FindFirstValue(ClaimTypes.NameIdentifier); int userId = _context.UserAccounts.Where(x => x.UserId == id).FirstOrDefault().ProfileId; var newFileName = string.Empty; BandSongSample addSong = new BandSongSample(); if (HttpContext.Request.Form.Files != null) { //var fileName = string.Empty; string PathDB = string.Empty; foreach (var file in files) { if (file.Length > 0) { var FileExtension = Path.GetExtension(file.FileName); newFileName = userId.ToString() + "_" + file.FileName; PathDB = "wwwroot/BandSongs/" + newFileName; addSong.FileName = "BandSongs/" + newFileName; using (FileStream fs = System.IO.File.Create(PathDB)) { file.CopyTo(fs); fs.Flush(); } } } } addSong.UserId = id; addSong.BandId = bandId; await _context.BandSongSamples.AddAsync(addSong); await _context.SaveChangesAsync(); BandSongSample sample = new BandSongSample(); sample.BandId = bandId; return(View("Create", sample)); }
internal Task RemoveAsync(BandSongSample song) { throw new NotImplementedException(); }