Ejemplo n.º 1
0
        public async Task <ActionResult> Create([Bind(Include = "IdiomId,IdiomName,CreatedDate,CreatedBy,LastUpdate,UpdatedBy")] Idiom idiom)
        {
            if (ModelState.IsValid)
            {
                db.Idioms.Add(idiom);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(idiom));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Create([Bind(Include = "CategoryId,CategoryName,CreatedDate,CreatedBy,LastUpdate,UpdatedBy")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Create([Bind(Include = "ArtistId,FirstName,LastName,CountryId,CreatedDate,CreatedBy,LastUpdate,UpdatedBy")] Artist artist)
        {
            if (ModelState.IsValid)
            {
                db.Artists.Add(artist);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "CountryName", artist.CountryId);
            return(View(artist));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Create([Bind(Include = "SongId,SongName,Lyrics,Author,CategoryId,IdiomId,CreatedDate,CreatedBy,LastUpdate,UpdatedBy")] Song song)
        {
            if (ModelState.IsValid)
            {
                db.Songs.Add(song);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", song.CategoryId);
            ViewBag.IdiomId    = new SelectList(db.Idioms, "IdiomId", "IdiomName", song.IdiomId);
            return(View(song));
        }
Ejemplo n.º 5
0
 public async Task UpdateAsync(User entity)
 {
     _dbContext.Entry(entity).State = EntityState.Modified;
     foreach (var lyrics in entity.Lyrics)
     {
         if (lyrics.Id == default)
         {
             _dbContext.Entry(entity).State = EntityState.Added;
         }
         else
         {
             _dbContext.Entry(entity).State = EntityState.Modified;
         }
     }
     await _dbContext.SaveChangesAsync();
 }
Ejemplo n.º 6
0
 public async Task CreateAsync(User entity)
 {
     _dbContext.Users.Add(entity);
     await _dbContext.SaveChangesAsync();
 }