Пример #1
0
        public async Task <Casting> Create(CreateCasting data,
                                           [Service] ICastingRepository repository,
                                           [Service] IActorRepository actors,
                                           [Service] IFilmRepository films)
        {
            var actor = await actors.GetById(data.Actor);

            var film = await films.GetById(data.Film);

            var casting = new Casting(film, actor, data.Role);
            await repository.Add(casting);

            return(casting);
        }
Пример #2
0
        public IActionResult Add(CastingViewModel castingViewModel)
        {
            if (ModelState.IsValid)
            {
                Casting casting = new Casting();
                casting.NewFromForm(castingViewModel);

                casting.CreatorId = getIdCurrentUser();
                _castingRepository.Add(casting);

                return(RedirectToAction("Index", "Account"));
            }

            return(View(castingViewModel));
        }