예제 #1
0
        public bool Update(ReadingModel readingModel)
        {
            var original = DatabaseManager.Instance.Reading.Find(readingModel.Id);

            if (original != null)
            {
                DatabaseManager.Instance.Entry(original).CurrentValues.SetValues(ToDbModel(readingModel));
                DatabaseManager.Instance.SaveChanges();
                return(true);
            }

            return(false);
        }
예제 #2
0
        private Reading ToDbModel(ReadingModel readingModel)
        {
            var readingDb = new Reading
            {
                ReadingPage         = readingModel.Page,
                ReadingModifiedDate = readingModel.ModifiedDate,
                ReadingAuthor       = readingModel.Author,
                ReadingId           = readingModel.Id,
                ReadingTitle        = readingModel.Title,
                ReadingNotes        = readingModel.Notes,
                ReadingType         = readingModel.Type,
            };

            return(readingDb);
        }
예제 #3
0
        public ReadingModel Add(ReadingModel readingModel)
        {
            var readingDb = ToDbModel(readingModel);

            DatabaseManager.Instance.Reading.Add(readingDb);
            DatabaseManager.Instance.SaveChanges();

            readingModel = new ReadingModel
            {
                Page         = readingDb.ReadingPage,
                ModifiedDate = readingDb.ReadingModifiedDate,
                Author       = readingDb.ReadingAuthor,
                Id           = readingDb.ReadingId,
                Title        = readingDb.ReadingTitle,
                Notes        = readingDb.ReadingNotes,
                Type         = readingDb.ReadingType
            };
            return(readingModel);
        }