Ejemplo n.º 1
0
        private UserMark InsertUserMark(int locationId, int colourIndex, int startToken, int endToken, int verseNumber)
        {
            var userMark = new UserMark
            {
                UserMarkId   = ++_maxUserMarkId,
                LocationId   = locationId,
                UserMarkGuid = Guid.NewGuid().ToString().ToLower(),
                Version      = 1,
                ColorIndex   = colourIndex
            };

            _targetDatabase.AddUserMarkAndUpdateIndex(userMark);

            // now add the block range...
            var blockRange = new BlockRange
            {
                BlockRangeId = ++_maxBlockRangeId,
                BlockType    = 2,
                Identifier   = verseNumber,
                StartToken   = startToken,
                EndToken     = endToken,
                UserMarkId   = userMark.UserMarkId
            };

            _targetDatabase.AddBlockRangeAndUpdateIndex(blockRange);

            return(userMark);
        }
Ejemplo n.º 2
0
        public async Task AddMark(ApplicationUser user, Guid flightId)
        {
            var userMark = new UserMark {
                FlightId = flightId, UserId = user.Id
            };
            await _context.UserMarks.AddAsync(userMark);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 3
0
        private void InsertUserMark(UserMark userMark, Database destination)
        {
            UserMark newUserMark = userMark.Clone();

            newUserMark.UserMarkId = ++_maxUserMarkId;
            newUserMark.LocationId = _translatedLocationIds.GetTranslatedId(userMark.LocationId);
            destination.UserMarks.Add(newUserMark);

            _translatedUserMarkIds.Add(userMark.UserMarkId, newUserMark.UserMarkId);
        }
Ejemplo n.º 4
0
        public IActionResult Delete(int id)
        {
            UserMark userMark = _db.UserMarks.FirstOrDefault(um => um.Id == id);

            if (userMark == null)
            {
                return(NotFound());
            }
            _db.UserMarks.Remove(userMark);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public IActionResult Index(UserMark newUserMark)
        {
            UserMark userMark = _db.UserMarks.FirstOrDefault(um => um.Id == newUserMark.Id);

            if (userMark != null)
            {
                return(Conflict());
            }
            _db.UserMarks.Add(newUserMark);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        private void InsertNote(BibleNote note)
        {
            var book    = note.BookChapterAndVerse.BookNumber;
            var chapter = note.BookChapterAndVerse.ChapterNumber;

            var location = _targetDatabase.FindLocationByBibleChapter(_bibleKeySymbol, book, chapter) ??
                           InsertLocation(book, chapter);

            UserMark userMark = null;

            if (note.StartTokenInVerse != null && note.EndTokenInVerse != null)
            {
                // the note should be associated with some
                // highlighted text in the verse.
                userMark = FindExistingUserMark(
                    location.LocationId,
                    note.StartTokenInVerse.Value,
                    note.EndTokenInVerse.Value) ??
                           InsertUserMark(
                    location.LocationId,
                    note.ColourIndex,
                    note.StartTokenInVerse.Value,
                    note.EndTokenInVerse.Value,
                    note.BookChapterAndVerse.VerseNumber);
            }

            var newNote = new Note
            {
                NoteId          = ++_maxNoteId,
                Guid            = Guid.NewGuid().ToString().ToLower(),
                UserMarkId      = userMark?.UserMarkId,
                LocationId      = location.LocationId,
                Title           = note.NoteTitle,
                Content         = note.NoteContent,
                BlockType       = 2,
                BlockIdentifier = note.BookChapterAndVerse.VerseNumber,
                LastModified    = Database.GetDateTimeUtcAsDbString(DateTime.UtcNow),
            };

            var newTagMapEntry = _options.TagId == 0
                ? null
                : CreateTagMapEntryForImportedBibleNote(newNote.NoteId, _options.TagId);

            _targetDatabase.AddBibleNoteAndUpdateIndex(
                note.BookChapterAndVerse,
                newNote,
                newTagMapEntry);
        }
Ejemplo n.º 7
0
        private static bool ShouldRemoveUnderlining(
            UserMark mark, Database database, int colorIndex, bool anyColor, string?publicationSymbol, bool anyPublication)
        {
            if (!anyColor && mark.ColorIndex != colorIndex)
            {
                return(false);
            }

            if (anyPublication)
            {
                return(true);
            }

            var location = database.FindLocation(mark.LocationId);

            return(location != null && location.KeySymbol == publicationSymbol);
        }
Ejemplo n.º 8
0
        public async Task AddMark(string userId, Guid flightId)
        {
            var user = await _context.Users.FindAsync(userId);

            var flight = await _context.Flights.FindAsync(flightId);

            if ((user == null) || (flight == null))
            {
                throw new Exception("User of flight not found");
            }

            var userMark = new UserMark {
                FlightId = flight.Id, UserId = user.Id
            };
            await _context.UserMarks.AddAsync(userMark);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 9
0
        private void AddUserMarkMutations(UserMarkFacade userMarkFacade)
        {
            Field <UserMarkType>("editUserMarkByUserList",
                                 arguments: new QueryArguments(new QueryArgument <NonNullGraphType <ListGraphType <UserMarkInputType> > > {
                Name = "userMarks"
            }),
                                 resolve: context => {
                List <UserMark> marks = context.GetArgument <List <UserMark> >("userMarks");

                foreach (UserMark mark in marks)
                {
                    if (mark.IssueData != null)
                    {
                        DateTime leftDate  = mark.IssueData.Value.AddMinutes(-1);
                        DateTime rightDate = mark.IssueData.Value.AddMinutes(1);

                        UserMark old = userMarkFacade.GetByUserMarkInputType(mark, leftDate, rightDate);
                        if (old == null)
                        {
                            userMarkFacade.Add(mark);
                        }
                        else
                        {
                            if (old.MarkId != mark.MarkId)
                            {
                                old.MarkId = mark.MarkId;
                                userMarkFacade.Update(old);
                            }
                        }
                    }
                }

                return(null);
            }
                                 );
        }
Ejemplo n.º 10
0
        public virtual string GetElementText(PacketElementID id)
        {
            switch (id)
            {
            case PacketElementID.Class:
            {
                return(Class);
            }

            case PacketElementID.Facility:
            {
                return(Facility.ToString());
            }

            case PacketElementID.Alias:
            {
                return(Alias);
            }

            case PacketElementID.Priority:
            {
                return(Priority.ToString());
            }

            case PacketElementID.Attribute:
            {
                return(Attribute.ToString());
            }

            case PacketElementID.DateTime_UTC_ISO8601:
            {
                return(MakeTime.ToUniversalTime().ToString("o"));
            }

            case PacketElementID.DateTime_UTC_Display:
            {
                return(MakeTime.ToUniversalTime().ToString(DATETIME_FORMAT_UTC_DISPLAY));
            }

            case PacketElementID.DateTime_Local_ISO8601:
            {
                return(MakeTime.ToLocalTime().ToString("o"));
            }

            case PacketElementID.DateTime_Local_Display:
            {
                return(MakeTime.ToLocalTime().ToString(DATETIME_FORMAT_LOCAL_DISPLAY));
            }

            case PacketElementID.Information:
            {
                return(Information);
            }

            case PacketElementID.Direction:
            {
                return(Direction.ToString());
            }

            case PacketElementID.Source:
            {
                return(Source);
            }

            case PacketElementID.Destination:
            {
                return(Destination);
            }

            case PacketElementID.Mark:
            {
                return(UserMark.ToString());
            }

            case PacketElementID.Data_BitString:
            {
                return(DataToBitString());
            }

            case PacketElementID.Data_HexString:
            {
                return(DataToHexString());
            }

            case PacketElementID.Data_TextAscii:
            {
                return(DataToText(Encoding.ASCII));
            }

            case PacketElementID.Data_TextUTF8:
            {
                return(DataToText(Encoding.UTF8));
            }

            case PacketElementID.Data_TextUTF16BE:
            {
                return(DataToText(Encoding.BigEndianUnicode));
            }

            case PacketElementID.Data_TextUTF16LE:
            {
                return(DataToText(Encoding.Unicode));
            }

            case PacketElementID.Data_TextShiftJIS:
            {
                return(DataToText(Encoding.GetEncoding(932)));
            }

            case PacketElementID.Data_TextEucJp:
            {
                return(DataToText(Encoding.GetEncoding(20932)));
            }

            default:
                return("");
            }
        }