Exemplo n.º 1
0
        public async Task SaveModel(TvProgrammeViewModel viewModel)
        {
            viewModel.AvatarUrl = await UploadAvatar(viewModel.AvatarFile);

            var model = _mapper.Map <TvProgramme>(viewModel);

            model.Channel = _userService.GetUser().TvStaff.Channel;

            _programmeRepository.Save(model);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Add(TvProgrammeViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            if (_programmePresentation.NameExist(viewModel.Name))
            {
                ViewBag.ErrorMsg = "This name already exists";
                return(View(viewModel));
            }
            else
            {
                await _programmePresentation.SaveModel(viewModel);

                return(View(viewModel));
            }
        }