Esempio n. 1
0
        public async Task Update(int id, TrackManipulationDto track)
        {
            var trackEntity = await _repositoryManager.TrackRepository.GetTrackAsync(id, true);

            _mapper.Map(track, trackEntity);
            await _repositoryManager.SaveAsync();
        }
Esempio n. 2
0
        public async Task <TrackReadDto> Create(int ProgramId, TrackManipulationDto track)
        {
            var trackEntityl = _mapper.Map <Track>(track);
            var tra          = _repositoryManager.TrackRepository.CreateTrack(ProgramId, trackEntityl);
            await _repositoryManager.SaveAsync();

            return(_mapper.Map <TrackReadDto>(tra));
        }
        public async Task <IActionResult> UpdateTrackForProgram(int trackId, [FromBody] TrackManipulationDto track)
        {
            try
            {
                await _manager.TrackServices.Update(trackId, track);

                return(NoContent());
            }
            catch (BadHttpRequestException)
            {
                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new { Status = "Error", Message = "Internal server error" }));
            }
        }
        public async Task <IActionResult> AddTrackToProgram(int programId, [FromBody] TrackManipulationDto track)
        {
            try
            {
                var program = await _manager.ProgramServices.GetProgram(programId);

                var tr = await _manager.TrackServices.Create(programId, track);

                return(Created("Track Created Successfully", tr));
            }
            catch (BadHttpRequestException)
            {
                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new { Status = "Error", Message = "Internal server error" }));
            }
        }