public CreateResponse Create(SaucerMultimediaRequest request, File file) { try { var saucerMultimedia = TypeAdapter.Adapt <SaucerMultimedia>(request); _saucerMultimediaValidator.ValidateAndThrowException(saucerMultimedia, "Base"); //_fileValidator.ValidateAndThrowException(file, "Base"); var savedFilePath = _storageProvider.Save(file); saucerMultimedia.Path = savedFilePath; _saucerMultimediaRepository.Add(saucerMultimedia); return(new CreateResponse(saucerMultimedia.Id)); } catch (DataAccessException) { throw new ApplicationException(); } }
public SuccessResponse Update(SaucerMultimediaRequest request) { try { var currentSaucerMultimedia = _saucerMultimediaRepository.FindBy(request.Id); currentSaucerMultimedia.ThrowExceptionIfRecordIsNull(); var saucerMultimediaToCopy = TypeAdapter.Adapt <SaucerMultimedia>(request); TypeAdapter.Adapt(saucerMultimediaToCopy, currentSaucerMultimedia); _saucerMultimediaValidator.ValidateAndThrowException(currentSaucerMultimedia, "Base"); _saucerMultimediaRepository.Update(currentSaucerMultimedia); return(new SuccessResponse { IsSuccess = true }); } catch (DataAccessException) { throw new ApplicationException(); } }
public SuccessResponse Put(SaucerMultimediaRequest request) { return(_saucerMultimediaService.Update(request)); }
public CreateResponse Post(SaucerMultimediaRequest request) { return(_saucerMultimediaService.Create(request, Request.GetFile())); }