public static void InitializeMigration() { using (var database = new SpartaHackDataStore()) { database.Database.Migrate(); } }
public List<Schedule> getScheduleLocal() { List<Schedule> data; using (var db = new SpartaHackDataStore()) { data = db.ScheduleItems.ToList(); } return data; }
public static void setCurrentUser(User user) { using (var db = new SpartaHackDataStore()) { if (db.CurrentUser.Count() > 0) { db.CurrentUser.Remove(db.CurrentUser.ElementAt(0)); db.SaveChanges(); } db.CurrentUser.Add(user); db.SaveChanges(); } }
public static User getCurrentUser() { User current = null; try { using (var db = new SpartaHackDataStore()) { current = db.CurrentUser.FirstOrDefault(); } } catch { } return current; }
public async Task<List<Schedule>> getSchedule() { List<Schedule> schedule = null; HttpClient client = new HttpClient(); var response = await client.GetAsync(APIConstants.Schedule); if (response.IsSuccessStatusCode) { var jsonString = await response.Content.ReadAsStringAsync(); schedule = JsonConvert.DeserializeObject<ScheduleResponse>(jsonString).schedule; using (var db = new SpartaHackDataStore()) { db.ScheduleItems.RemoveRange(db.ScheduleItems); db.SaveChanges(); db.ScheduleItems.AddRange(schedule); db.SaveChanges(); } } return schedule; }