public static Comparison[] SeedTwoCompsToUser(MomentoDbContext context, string userId) { var user = context.Users.SingleOrDefault(x => x.Id == userId); var comps = new List <Comparison>(); comps.Add(new Comparison { Description = "", Name = "", Order = 0, TargetLanguage = "", SourceLanguage = "", UserId = user.Id, DirectoryId = user.Directories.SingleOrDefault().Id, }); comps.Add(new Comparison { Description = "", Name = "", Order = 0, TargetLanguage = "", SourceLanguage = "", UserId = user.Id, DirectoryId = user.Directories.SingleOrDefault().Id, }); context.AddRange(comps); context.SaveChanges(); return(comps.ToArray()); }
public static CodeLine[] SeedTwoCodeLinesToNote(Note note, MomentoDbContext context) { var line1 = new CodeLine { EditorMode = line1EditorMode, InPageId = line1InPageId, NoteContent = line1NoteContent, Visible = line1Visible, Order = line1Order, SourceContent = line1SourceContent, Note = note, }; var line2 = new CodeLine { EditorMode = line2EditorMode, InPageId = line2InPageId, NoteContent = line2NoteContent, Visible = line2Visible, Order = line2Order, SourceContent = line2SourceContent, Note = note, }; var lines = new CodeLine[] { line1, line2 }; context.CodeLines.AddRange(lines); context.SaveChanges(); return(lines); }
/// <summary> /// Also seeds their root directories! /// </summary> public static void SeedPeshoAndGosho(MomentoDbContext context) { var users = new User[] { new User { Id = PeshoId, FirstName = "Pesho", LastName = "Peshov", UserName = PeshoUsername, Email = "*****@*****.**", Directories = new Directory[] { new Directory { Name = PeshoRootDir, Id = PeshoRootDirId } } }, new User { Id = GoshoId, FirstName = "Gosho", LastName = "Goshov", UserName = GoshoUsername, Email = "*****@*****.**", Directories = new Directory[] { new Directory { Name = GoshoRootDir, Id = GoshoRootDirId } } }, }; context.Users.AddRange(users); context.SaveChanges(); }
public static ComparisonItem[] SeedThreeItemsToComp(MomentoDbContext context, Comparison comp) { var items = new HashSet <ComparisonItem> { new ComparisonItem { Id = 1, Comment = "item1Comment", Order = 1, Target = "item1Target", Source = "item1Source", }, new ComparisonItem { Id = 2, Comment = "item2Comment", Order = 2, Target = "item2Target", Source = "item2Source", }, new ComparisonItem { Id = 3, Comment = "item3Comment", Order = 3, Target = "item3Target", Source = "item3Source", }, }; comp.Items = items; context.SaveChanges(); return(items.ToArray()); }
public VideoService( MomentoDbContext context, ITrackableService trackableService) { this.context = context; this.trackableService = trackableService; }
public static Video SeedVideosToUserWithNotes(MomentoDbContext context, string userId, bool nestedNote = false) { var user = context.Users.SingleOrDefault(x => x.Id == userId); var rootDirectoryId = user.Directories.FirstOrDefault(x => x.Name.Contains("Root")).Id; var note1 = new VideoNote { Order = 0, Id = preExistingNote1Id, Content = preExistingNote1Content, Formatting = DefaultNoteFormatting, SeekTo = DefaultNoteSeekTo, }; var note2 = new VideoNote { Order = 2, Id = preExistingNote2Id, Content = preExistingNote2Content, Formatting = DefaultNoteFormatting, SeekTo = DefaultNoteSeekTo, }; var video = new Video { UserId = userId, Name = DefaultVideoName, Description = DefaultVideoDesctiption, SeekTo = DefaultVideoSeekTo, Url = DefaultVideoUrl, DirectoryId = rootDirectoryId, Notes = new HashSet <VideoNote> { note1, note2, } }; if (nestedNote) { var note3 = new VideoNote { Order = 1, Id = preExistingNote3Id, Content = preExistingNote3Content, Formatting = DefaultNoteFormatting, SeekTo = DefaultNoteSeekTo, Video = video, }; note1.ChildNotes = new HashSet <VideoNote> { note3 }; } user.Videos.Add(video); context.SaveChanges(); return(video); }
public NoteService( MomentoDbContext context, IUtilitiesService utilService, ITrackableService trackableService) { this.context = context; this.utilService = utilService; this.trackableService = trackableService; }
public ListToDoService( MomentoDbContext context, ITrackableService trackableService, IUserService userService, IReorderingService reorderingService) { this.context = context; this.trackableService = trackableService; this.userService = userService; this.reorderingService = reorderingService; }
public virtual void Setup() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <MomentoDbContext>() .UseSqlite(connection) .Options; this.context = new MomentoDbContext(options); context.Database.EnsureCreated(); }
public static void DetachAll(MomentoDbContext context) { var changedEntriesCopy = context.ChangeTracker.Entries() .Where(e => e.State == EntityState.Added || e.State == EntityState.Modified || e.State == EntityState.Deleted || e.State == EntityState.Unchanged) .ToArray(); for (int i = 0; i < changedEntriesCopy.Length; i++) { var entry = changedEntriesCopy[i].Entity; context.Entry(entry).State = EntityState.Detached; } }
public static Video SeedVideosToUser(MomentoDbContext context, string userId) { var user = context.Users.SingleOrDefault(x => x.Id == userId); var directoryId = user.Directories.FirstOrDefault(x => x.Name.Contains("Root")).Id; var video = new Video { DirectoryId = directoryId, UserId = userId, Name = "TestVideo1", }; context.Videos.Add(video); context.SaveChanges(); return(video); }
public static Note SeedNoteToUser(string userId, MomentoDbContext context) { var user = context.Users.SingleOrDefault(x => x.Id == userId); var note = new Note { Description = NoteDesctiption, Directory = user.Directories.First(), Lines = new HashSet <CodeLine>(), MainNoteContent = NoteMainNoteContent, Name = NoteName, EditorMode = false, Order = 0, User = user, ShowSourceEditor = false, Source = "", }; context.Notes.Add(note); context.SaveChanges(); return(note); }
public ReorderingService(MomentoDbContext context) { this.context = context; }
public TrackableService(MomentoDbContext context) { this.context = context; }
public ComparisonService(MomentoDbContext context) { this.context = context; }
public UserService(MomentoDbContext context) { this.context = context; }
public SaveData(MomentoDbContext context) { this.context = context; }
public DirectoryService(MomentoDbContext context, IMapper mapper) { this.context = context; this.mapper = mapper; }
public ListRemindService(MomentoDbContext context) { this.context = context; }
public CodeService(MomentoDbContext context, IMapper mapper) { this.context = context; this.mapper = mapper; }
public LayoutViewService(IHttpContextAccessor httpContext, MomentoDbContext context) { this.context = context; }
public SettingsService(MomentoDbContext context, IUserService userService) { this.context = context; this.userService = userService; }
public SoftDeleteService(MomentoDbContext context) { this.context = context; }