Example #1
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();
 }
Example #2
0
        public async Task <ActionResult> Edit([Bind(Include = "IdiomId,IdiomName,CreatedDate,CreatedBy,LastUpdate,UpdatedBy")] Idiom idiom)
        {
            if (ModelState.IsValid)
            {
                db.Entry(idiom).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(idiom));
        }
        public async Task <ActionResult> Edit([Bind(Include = "CategoryId,CategoryName,CreatedDate,CreatedBy,LastUpdate,UpdatedBy")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Entry(category).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(category));
        }
Example #4
0
        public async Task <ActionResult> Edit([Bind(Include = "ArtistId,FirstName,LastName,CountryId,CreatedDate,CreatedBy,LastUpdate,UpdatedBy")] Artist artist)
        {
            if (ModelState.IsValid)
            {
                db.Entry(artist).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "CountryName", artist.CountryId);
            return(View(artist));
        }
Example #5
0
        public async Task <ActionResult> Edit([Bind(Include = "SongId,SongName,Lyrics,Author,CategoryId,IdiomId,CreatedDate,CreatedBy,LastUpdate,UpdatedBy")] Song song)
        {
            if (ModelState.IsValid)
            {
                db.Entry(song).State = EntityState.Modified;
                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));
        }
Example #6
0
 public async Task DeleteAsync(User entity)
 {
     _dbContext.Entry(entity).State = EntityState.Deleted;
     await _dbContext.SaveChangesAsync();
 }