Ejemplo n.º 1
0
        public async Task <IActionResult> PutArtist(int id, Artist artist)
        {
            if (id != artist.Id)
            {
                return(BadRequest());
            }

            _context.Entry(artist).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArtistExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <Song> > PutSong(int id, Song song)
        {
            try
            {
                if (id != song.Id)
                {
                    return(BadRequest());
                }
                _context.Entry(song).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(song);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SongExists(id))
                {
                    log.Error(Constant.UnknownException);
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutSong(long id, Song song)
        {
            if (id != song.Id)
            {
                return(BadRequest());
            }

            _context.Entry(song).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SongExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutAppearance(int id, Appearance appearance)
        {
            if (id != appearance.EpisodeId)
            {
                return(BadRequest());
            }

            _context.Entry(appearance).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppearanceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "Id,Name,Age,Band")] Artist artist)
 {
     if (ModelState.IsValid)
     {
         db.Entry(artist).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(artist));
 }
Ejemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "ID,Title,Artist,Album,Length,Genre")] Song song)
 {
     if (ModelState.IsValid)
     {
         db.Entry(song).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(song));
 }
Ejemplo n.º 7
0
        // PUT api/Song/5
        public HttpResponseMessage PutSong(int id, Song song)
        {
            if (ModelState.IsValid && id == song.SongID)
            {
                db.Entry(song).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, song));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
Ejemplo n.º 8
0
 public void UpdateSong(Song song)
 {
     _dbContext.Entry(song).State = EntityState.Modified;
     Save();
 }