public override void FileEdited(FileResponse res, FileEditRequest req) { //foreach (var resizedImage in GetResizedImageMetaData(req.FileId).Select(x=>x.MetaData.ToObject<ResizedImage>())) //{ //}to do }
public void When_Type_Expected_AnErrorIsThrown() { var file = new FileEditRequest() { }; _editRequestValidator.ShouldHaveValidationErrorFor(c => c.Type, file); }
public void When_ContentEmpty_Expected_AnErrorIsThrown() { var file = new FileEditRequest() { }; _editRequestValidator.ShouldHaveValidationErrorFor(c => c.Content, file); }
public async Task <FileResponse> Edit(FileEditRequest request) { var res = await _fileService.Edit(request); if (res.Access == ResponseAccess.Granted) { _observers.ForEach(x => x.FileEdited(res, request)); await _unitOfWork.SaveChangesAsync(); } return(res); }
public async Task <FileResponse> Edit(FileEditRequest request) { var editingFile = _fileDataService.Query.First(x => x.Id == request.FileId); if (editingFile.Name != request.ViewModel.Name) { await BeCareFullAboutBothDataAndFileChangesAndDoTheRestEdit(editingFile, request); } else { await DoTheRestEdit(editingFile, request); } return(new FileResponse() { Access = ResponseAccess.Granted, Model = editingFile.MapToViewModelWithMeta(request.ViewModel.MetaDatas.MapToModelList()) }); }
public async Task <CampaignServiceErrorResponseModel> UpdateImage(FileEditRequest model) { try { var file = _mapper.Map <FileModel>(model); await _burnRuleService.SaveBurnRuleContentImage(file); return(new CampaignServiceErrorResponseModel() { ErrorCode = CampaignServiceErrorCodes.None }); } catch (RuleConditionNotFileException ex) { _log.Info(string.Format(Phrases.InvalidContentType), context: model.RuleContentId); return(new CampaignServiceErrorResponseModel() { ErrorCode = CampaignServiceErrorCodes.NotValidRuleContentType, ErrorMessage = ex.Message }); } catch (EntityNotFoundException e) { _log.Info(string.Format(Phrases.EntityWithIdNotFound, "Burn rule", model.RuleContentId), context: model.RuleContentId); return(new CampaignServiceErrorResponseModel() { ErrorCode = CampaignServiceErrorCodes.EntityNotFound, ErrorMessage = e.Message }); } catch (NotValidFormatFile ex) { _log.Info(string.Format(Phrases.NotValidFormatFile), context: model.Type); return(new CampaignServiceErrorResponseModel() { ErrorCode = CampaignServiceErrorCodes.NotValidFileFormat, ErrorMessage = ex.Message }); } }
private async Task DoTheRestEdit(DomainClasses.Entities.FileData editingFile, FileEditRequest request) { request.ViewModel.MapToExisting(editingFile); UpdateMetaDatas(request.ViewModel.MetaDatas.Where(x => x.HasChanges).ToList()); await base.BaseBeforeUpdateAsync(editingFile, request.RequestOwner); await _fileDataService.UpdateAsync(editingFile); await base.BaseAfterUpdateAsync(editingFile, request.RequestOwner); }
private async Task BeCareFullAboutBothDataAndFileChangesAndDoTheRestEdit(DomainClasses.Entities.FileData editingFile, FileEditRequest request) { var oldName = editingFile.Name; var fileEditRes = _fileManager.Rename(_appDir + editingFile.Path, request.ViewModel.Name, request.ViewModel.ActionPrompt); editingFile.Path = fileEditRes.SavedFilePath; try { await DoTheRestEdit(editingFile, request); } catch (Exception e) { _fileManager.Rename(_appDir + fileEditRes.SavedFilePath, oldName, request.ViewModel.ActionPrompt); throw; } }
public abstract void FileEdited(FileResponse res, FileEditRequest req);