Exemplo n.º 1
0
        public IActionResult Add(TvChannelViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            if (_channelPresentation.NameExist(viewModel.Name))
            {
                ViewBag.ErrorMsg = "This name already exists";
                return(View(viewModel));
            }
            else
            {
                _channelPresentation.Save(viewModel);
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 2
0
        public void Save(TvChannelViewModel viewModel)
        {
            var model = _mapper.Map <TvChannel>(viewModel);

            _channelRepository.Save(model);
        }