public async Task <IActionResult> Create([Bind("ArtistSkillId,TalentName,SkillLevel,Details,Styles")] ArtistSkill artistSkill) { if (ModelState.IsValid) { _context.Add(artistSkill); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(artistSkill)); }
public async Task <IActionResult> Create([Bind("ArtistId,UserName,Country,Provence,City,WebSite,CreatedDate")] Artist artist) { if (ModelState.IsValid) { _context.Add(artist); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(artist)); }
public async Task <IActionResult> Create([Bind("RecordId,Name,ReleasedYear,NrOfTunes,TotalLength,Created,ArtistId")] Record record) { if (ModelState.IsValid) { _context.Add(record); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ArtistId"] = new SelectList(_context.Artists, "ArtistId", "Name", record.ArtistId); return(View(record)); }
public async Task <IActionResult> Create([Bind("UserId,Name,RentedWhen,RecordId")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["RecordId"] = new SelectList(_context.Records, "RecordId", "Name", user.RecordId); return(View(user)); }
public async Task <IActionResult> Create([Bind("ArtistId,Name,Age,Gender,Url,Salary,Created")] Artist artist) { if (ModelState.IsValid) { //Capitalize the gender variable artist.Gender = char.ToUpper(artist.Gender[0]).ToString() + artist.Gender.Substring(1); _context.Add(artist); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(artist)); }
public ActionResult Create(Artist artist) { try { var context = new ArtistContext(); context.Add(artist, "TestUser"); //TODO Productデータがなかったら取得スレッドを動かすかどうか検討 //TODO その場合Redis登録時にすでに存在するかの判定が必要 return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <IActionResult> Create([Bind("ArtistId,ArtistName,ArtistDesc,ArtistCity,ArtistIg,ArtistPicture")] Artist artist) { if (ModelState.IsValid) { string wwwRootPath = _hostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(artist.ArtistPicture.FileName); string extension = Path.GetExtension(artist.ArtistPicture.FileName); artist.ImageName = fileName = fileName + extension; string path = Path.Combine(wwwRootPath + "/Images/Artist/", fileName); using (var fileStream = new FileStream(path, FileMode.Create)) { await artist.ArtistPicture.CopyToAsync(fileStream); } _context.Add(artist); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(artist)); }
public IEnumerable <Artist> GetArtistsSecret() { var Bus = RabbitHutch.CreateBus("host=localhost"); ConcurrentStack <Artist> artistsCollection = new ConcurrentStack <Artist>(); Bus.Receive <RabbitArtist>("artist", msg => { Artist artist = new Artist() { ArtistName = msg.ArtistName, LastFmRating = msg.LastFmRating }; artistsCollection.Push(artist); }); Thread.Sleep(5000); foreach (Artist a in artistsCollection) { _context.Add(a); } _context.SaveChanges(); return(_context.Artists); }
void GenerateData() { for (int i = 0; i < 30; ++i) { var tracks = new List<Track>(); var albums = new List<Album>(); var genre = new Genre() { Name = "Rock" }; var artist = new Artist() { Name = "Name", Genre = genre, Albums = albums }; albums.Add(new Album() { Name = "Album", Artist = artist, Tracks = tracks }); tracks.Add(new Track() { Name = "Track", Artist = artist, Album = albums[0], Duration = 10, }); _artistContext.Add(artist); } _artistContext.SaveChanges(); }