Exemple #1
0
        public async Task <ActionResult <MatchBroadcastDto> > Delete(int id)
        {
            MatchBroadcast broadCast = await _unitOfWork.GetRepository().FindByIdAsync(id);

            if (broadCast == null)
            {
                return(NotFound());
            }

            _unitOfWork.GetRepository().Remove(broadCast);
            _unitOfWork.SaveChanges();
            return(Ok(_mapper.Map <MatchBroadcastDto>(broadCast)));
        }
Exemple #2
0
        public async Task <ActionResult <MatchBroadcastDto> > Put([FromBody] MatchBroadcast matchBroadcastDto)
        {
            if (matchBroadcastDto == null)
            {
                return(BadRequest());
            }
            if (_unitOfWork.GetRepository().GetAll().All(x => x.Id != matchBroadcastDto.Id))
            {
                return(NotFound());
            }

            var broadcast = _mapper.Map <MatchBroadcast>(matchBroadcastDto);

            _unitOfWork.GetRepository().Update(broadcast);

            _unitOfWork.SaveChanges();
            return(Ok(broadcast));
        }