示例#1
0
        public ActionResult Edit(Album album)
        {
            if (ModelState.IsValid)
            {
                var validationResult = _albumAppService.Update(album);

                if (validationResult.IsValid)
                {
                    return(RedirectToAction("Index"));
                }

                foreach (var error in validationResult.Errors)
                {
                    ModelState.AddModelError("", error.Message);
                }

                return(View(album));
            }
            ViewBag.GenreId  = new SelectList(_genreAppService.All(@readonly: true), "GenreId", "Name", album.GenreId);
            ViewBag.ArtistId = new SelectList(_artistAppService.All(@readonly: true), "ArtistId", "Name", album.ArtistId);
            return(View(album));
        }
示例#2
0
 public IActionResult Put([FromBody] AlbumUpdatingModel model)
 {
     try
     {
         return(StatusCode(200, App.Update(model)));
     }
     catch (EntityNotFoundException ex)
     {
         return(StatusCode(404, ex.ToString()));
     }
     catch (ValidationException ex)
     {
         return(StatusCode(400, ex.ToString()));
     }
     catch (InternalServerException ex)
     {
         return(StatusCode(500, ex.ToString()));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.ToString()));
     }
 }