예제 #1
0
 public IActionResult Create([Bind] SingerDetailEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var singer = model.ToSinger();
         _singerMapper.Create(singer);
         return(RedirectToAction(nameof(Admin)));
     }
     return(View(model));
 }
예제 #2
0
        public IActionResult Edit(int id, [Bind] SingerDetailEditViewModel model)
        {
            if (id != model.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var singer = model.ToSinger();
                _singerMapper.Update(singer);
                return(RedirectToAction(nameof(Admin)));
            }

            return(View(model));
        }
예제 #3
0
        public IActionResult AdminDetails(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var singer = _singerMapper.Find(id.Value);

            if (singer == null)
            {
                return(NotFound());
            }
            var model = new SingerDetailEditViewModel(singer);

            return(View(model));
        }