예제 #1
0
        public bool UpdateProgress(TrackerModel trackerModel)
        {
            var original = DatabaseManager.Instance.Trackings.Find(trackerModel.Id);

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

            return(false);
        }
예제 #2
0
        private Tracking ToDbModel(TrackerModel trackerModel)
        {
            var trackerDb = new Tracking
            {
                Id      = trackerModel.Id,
                Name    = trackerModel.Name,
                Type    = trackerModel.Type,
                Genre   = trackerModel.Genre,
                Current = trackerModel.Current,
                Total   = trackerModel.Total
            };

            return(trackerDb);
        }
예제 #3
0
        public TrackerModel Add(TrackerModel trackerModel)
        {
            var trackerDb = ToDbModel(trackerModel);

            DatabaseManager.Instance.Trackings.Add(trackerDb);
            DatabaseManager.Instance.SaveChanges();

            trackerModel = new TrackerModel
            {
                Id      = trackerDb.Id,
                Name    = trackerDb.Name,
                Type    = trackerDb.Type,
                Genre   = trackerDb.Genre,
                Current = trackerDb.Current,
                Total   = trackerDb.Total
            };
            return(trackerModel);
        }