Esempio n. 1
0
        public async Task <Season> CreateSeasonFromCreateViewModelAsync(CreateSeasonViewModel model)
        {
            var season = _mapper.Map <Season>(model);
            var title  = await _titleService.GetTitleAsync(model.TitleId);

            if (title == null)
            {
                return(null);
            }

            season.Title = title;

            var existSeason = _seasonContext.FirstOrDefault(x => x.TitleId == season.TitleId && x.Name == season.Name);

            if (existSeason != null)
            {
                return(null);
            }

            if (await CreateSeasonAsync(season))
            {
                return(season);
            }

            return(null);
        }