public void UpdateTrailer(TrailerViewModel trailer) { var trailerToRemove = _trailerRepository.GetById(trailer.TrailerC); var updateTrailer = Mapper.Map <TrailerViewModel, Trailer_M>(trailer); _trailerRepository.Delete(trailerToRemove); _trailerRepository.Add(updateTrailer); SaveTrailer(); }
public async Task <ActionResult> DeleteTrailer(int trailerId) { try { var oldTrailer = await _trailerRepository.GetTrailerById(trailerId); if (oldTrailer == null) { return(NotFound($"Could not find trailer with id {trailerId}")); } _trailerRepository.Delete(oldTrailer); if (await _trailerRepository.Save()) { return(NoContent()); } } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}")); } return(BadRequest()); }