コード例 #1
0
        public async Task <IActionResult> PutMovieAsync(long id, [FromBody] Movie movie)
        {
            if (id != movie.MovieID)
            {
                return(BadRequest(new { general = "There was an unexpected error. Try again later." }));
            }

            Dictionary <string, string> errors = movie.Validate();

            if (errors.Count == 0)
            {
                _context.Entry(movie).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(NoContent());
            }
            return(BadRequest(errors));
        }
コード例 #2
0
        public async Task <IActionResult> PutRoomAsync(int id, [FromBody] Room updatedRoom)
        {
            if (id != updatedRoom.RoomID)
            {
                return(BadRequest(new { general = "Failed to update room." }));
            }

            Dictionary <string, string> errors = updatedRoom.Validate();

            if (errors.Count == 0)
            {
                _context.Entry(updatedRoom).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(NoContent());
            }
            return(BadRequest(errors));
        }
コード例 #3
0
        public async Task <IActionResult> PutExperienceAsync(int id, [FromBody] Experience experience)
        {
            if (id != experience.ExperienceID)
            {
                return(BadRequest(new { general = "Failed to update experience" }));
            }

            Dictionary <string, string> errors = experience.Validate();

            if (errors.Count == 0)
            {
                _context.Entry(experience).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(NoContent());
            }
            return(BadRequest(errors));
        }