コード例 #1
0
        public async Task <AddAndUpdateTheaterPerformanceDTO> UpdateTheaterPerformance
            (int id, AddAndUpdateTheaterPerformanceDTO theaterPerformanceDTO)
        {
            TheaterPerformance theaterPerformance = _mapper.Map <TheaterPerformance>(theaterPerformanceDTO);

            theaterPerformance.Id = id;
            await _theaterPerformanceRepository.UpdateAsync(theaterPerformance);

            return(_mapper.Map <AddAndUpdateTheaterPerformanceDTO>(theaterPerformance));
        }
コード例 #2
0
        public async Task <IActionResult> AddPerformance
            ([FromBody] AddAndUpdateTheaterPerformanceDTO theaterPerformanceDTO)
        {
            var added = await _theaterPerformanceService.AddTheaterPerformance(theaterPerformanceDTO);

            if (added == null)
            {
                return(BadRequest());
            }
            return(Ok(added));
        }
コード例 #3
0
        public async Task <IActionResult> UpdateTheaterPerformance
            (int id, AddAndUpdateTheaterPerformanceDTO theaterPerformanceDTO)
        {
            var updatedTheaterPerformance =
                await _theaterPerformanceService.UpdateTheaterPerformance(id, theaterPerformanceDTO);

            if (updatedTheaterPerformance == null)
            {
                return(NotFound());
            }
            return(Ok(updatedTheaterPerformance));
        }
コード例 #4
0
        public async Task <AddAndUpdateTheaterPerformanceDTO> AddTheaterPerformance
            (AddAndUpdateTheaterPerformanceDTO theaterPerformanceDTO)
        {
            TheaterPerformance theaterPerformance = _mapper.Map <TheaterPerformance>(theaterPerformanceDTO);

            _theaterPerformanceRepository.Insert(theaterPerformance);
            _theaterPerformanceRepository.Save();


            TheaterPerformance addedTheaterPerformance =
                await _theaterPerformanceRepository.GetTheaterPerformance(theaterPerformance.Id);

            IEnumerable <User> usersToSendEmail = await GetUsersToSentEmail(addedTheaterPerformance);

            await _emailService.SendNewPerformanceEmail(_mapper.Map <IEnumerable <UserDTO> >(usersToSendEmail),
                                                        _mapper.Map <TheaterPerformanceDTO>(addedTheaterPerformance));


            return(_mapper.Map <AddAndUpdateTheaterPerformanceDTO>(theaterPerformance));
        }