Пример #1
0
        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());
        }
Пример #2
0
        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);
        }
Пример #3
0
        /// <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();
        }
Пример #4
0
        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());
        }
Пример #5
0
 public VideoService(
     MomentoDbContext context,
     ITrackableService trackableService)
 {
     this.context          = context;
     this.trackableService = trackableService;
 }
Пример #6
0
        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);
        }
Пример #7
0
 public NoteService(
     MomentoDbContext context,
     IUtilitiesService utilService,
     ITrackableService trackableService)
 {
     this.context          = context;
     this.utilService      = utilService;
     this.trackableService = trackableService;
 }
Пример #8
0
 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();
        }
Пример #10
0
        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;
            }
        }
Пример #11
0
        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);
        }
Пример #12
0
        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);
        }
Пример #13
0
 public ReorderingService(MomentoDbContext context)
 {
     this.context = context;
 }
Пример #14
0
 public TrackableService(MomentoDbContext context)
 {
     this.context = context;
 }
Пример #15
0
 public ComparisonService(MomentoDbContext context)
 {
     this.context = context;
 }
Пример #16
0
 public UserService(MomentoDbContext context)
 {
     this.context = context;
 }
Пример #17
0
 public SaveData(MomentoDbContext context)
 {
     this.context = context;
 }
Пример #18
0
 public DirectoryService(MomentoDbContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
Пример #19
0
 public ListRemindService(MomentoDbContext context)
 {
     this.context = context;
 }
Пример #20
0
 public CodeService(MomentoDbContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
Пример #21
0
 public LayoutViewService(IHttpContextAccessor httpContext, MomentoDbContext context)
 {
     this.context = context;
 }
Пример #22
0
 public SettingsService(MomentoDbContext context, IUserService userService)
 {
     this.context     = context;
     this.userService = userService;
 }
Пример #23
0
 public SoftDeleteService(MomentoDbContext context)
 {
     this.context = context;
 }