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); }
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); }
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); }