public async Task <bool> Handle(CreateDiscCommand message, CancellationToken cancellationToken) { var disc = Disc.DiscFactory.NewDisc(message.Name, message.Genre); if (!IsValid(disc)) { return(false); } await discRepository.Add(disc); return(await Commit()); }
public OperationResult Import(DvdFolderToImport dvdFolder) { try { dvdFolder.DatabaseId = discRepository.Add(dvdFolder); dvdFolder.SetFilesDiscId(); AddFilesToDatabase(dvdFolder); var fileDtosFromDatabase = fileRepository.GetByDisc((int)dvdFolder.DatabaseId); dvdFolder.SetFilesIdsFromDatabase(fileDtosFromDatabase); var joinDtos = dvdFolder.GetPerformerFilenameJoinDtos(); performerRepository.JoinPerformerToFile(joinDtos); } catch (Exception e) { Log.Error(e, "Import failed!"); return(new OperationResult() { Success = false, Message = $"Error importing {dvdFolder.DiscName}" }); } return(new OperationResult() { Success = true, Message = null }); }