Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,Name,AirTime,SortOrder")] Season season)
        {
            if (ModelState.IsValid)
            {
                _context.Add(season);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(season));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Label,SortOrder,Color")] Era era)
        {
            if (ModelState.IsValid)
            {
                _context.Add(era);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = era.Id }));
            }
            return(View(era));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Artist artist)
        {
            if (ModelState.IsValid)
            {
                _context.Add(artist);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = artist.Id }));
            }
            return(View(artist));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Singer,Author,Description,Thumbnail,Link")] Song song)
        {
            if (ModelState.IsValid)
            {
                _context.Add(song);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(song));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,EpisodeNumber,Name,SeasonId,Director,Writer,AirDate,ProdCode")] Episode episode)
        {
            if (ModelState.IsValid)
            {
                _context.Add(episode);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SeasonId"] = new SelectList(_context.Seasons, "Id", "Name", episode.SeasonId);
            return(View(episode));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,Name,ArtistId,EraId")] Song song)
        {
            if (ModelState.IsValid)
            {
                _context.Add(song);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = song.Id }));
            }
            BindViewBag(song);
            return(View(song));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Save SearchData datastructure to the database
        /// </summary>
        /// <param name="searchData"></param>
        /// <param name="BPM"></param>
        private void AddSearchDataToDB(Dictionary <uint, List <ulong> > searchData, int BPM)
        {
            // Iterate through all hashes
            foreach (KeyValuePair <uint, List <ulong> > hashWithSongValues in searchData)
            {
                // Iterate through all songValues
                foreach (ulong songValue in hashWithSongValues.Value)
                {
                    // Create database Hash
                    DatabaseHash databaseHash = new DatabaseHash
                    {
                        BPM       = BPM,
                        Hash      = hashWithSongValues.Key,
                        SongValue = songValue,
                    };

                    // Add hash to the database
                    _context.Add(databaseHash);
                }
            }
        }
 public async Task <IActionResult> Create(Appearance appearance, [FromForm] bool IsEpisode)
 {
     if (ModelState.IsValid)
     {
         if (!await AppearanceExists(appearance.SongId, appearance.EpisodeId))
         {
             _context.Add(appearance);
             await _context.SaveChangesAsync();
         }
         if (!IsEpisode)
         {
             return(RedirectToAction("Details", "Songs", new { id = appearance.SongId }));
         }
         else
         {
             return(RedirectToAction("Details", "Episodes", new { id = appearance.EpisodeId }));
         }
     }
     ViewData["EpisodeId"] = new SelectList(GetEpisodes(), "Id", "Name", appearance.EpisodeId);
     ViewData["SongId"]    = new SelectList(GetSongs(), "Id", "Name", appearance.SongId);
     return(View(appearance));
 }
Ejemplo n.º 9
0
 public void InsertSong(Song song)
 {
     _dbContext.Add(song);
     Save();
 }