public static GoalModel GetGoal(int id) { using (var db = new GoalContext()) { return(db.Goals.Where(x => x.ID == id).FirstOrDefault()); } }
public static void Update(int id, TextView tvContent, LinearLayout linearLayout) { GoalContext goalContext = GetGoalContext(id); goalContext.tvContent = tvContent; goalContext.LinearLayout = linearLayout; }
public void OnItemSelected(AdapterView parent, View view, int position, long id) { string goalTime = (string)Singleton.Instance.GoalSpinner.SelectedItem; if (goalTime == "Day") { Singleton.Instance.MonthSpinner.Visibility = ViewStates.Visible; } else { Singleton.Instance.MonthSpinner.Visibility = ViewStates.Gone; } GoalTimeDao.Update(goalTime); var obj = new GoalFragmentAdapter(Singleton.Instance.GoalActivity.SupportFragmentManager); Singleton.Instance.GoalViewPager.Adapter = obj; Singleton.Instance.GoalViewPager.AddOnPageChangeListener(new GoalFragmentPagerChangeListener()); var instance = Singleton.Instance; for (int i = 0; i < obj.Count; i++) { GoalContext goalContext = GoalContextDao.GetGoalContext(i); if (goalContext.IsViewCreated) { goalContext.UpdateTextView(); } else { break; } } }
public static void Initialize(IApplicationBuilder app) { GoalContext context = app.ApplicationServices .GetRequiredService <GoalContext>(); //context.Database.Migrate(); if (!context.Goal.Any()) { context.Goal.AddRange( new Goal { Title = "You can add tasks by pressing create new" }, new Goal { Title = "And delete them with the delete button", }, new Goal { Title = "Hope this helps!", } ); context.SaveChanges(); } }
public static IEnumerable <GoalModel> GetGoals() { using (var db = new GoalContext()) { return(db.Goals.ToList()); } }
public JournalEntriesController(JournalEntryContext contextJE, GoalContext contextGoal, PromptContext contextPrompt, UserDataContext contextUser, IConfiguration configuration, KeyVaultClient keyVaultClient) { _journalEntryService = new JournalEntryService(configuration, keyVaultClient); _contextJE = contextJE; _contextGoal = contextGoal; _contextUser = contextUser; _contextPrompt = contextPrompt; }
public static void Insert(GoalContext goalContext) { if (Singleton.Instance.GoalContexts == null) { Singleton.Instance.GoalContexts = new System.Collections.Generic.List <GoalContext>(); } Singleton.Instance.GoalContexts.Add(goalContext); }
public GoalController(GoalContext context) { _context = context; if (_context.Goals.Count() == 0) { _context.Goals.Add(new Goal { Name = "Get started by changing this goal, or add a new goal!", IsCompleted = false }); _context.SaveChanges(); } }
public static bool CreateNewGoal(GoalModel Goal) { if (Goal == null) { return(false); } using (var db = new GoalContext()) { db.Goals.Add(Goal); db.SaveChanges(); return(true); } }
public static bool DeleteGoal(int id) { if (id <= 0) { return(false); } using (var db = new GoalContext()) { var goal = db.Goals.Where(x => x.ID == id).FirstOrDefault(); db.Goals.Remove(goal); db.SaveChanges(); return(true); } }
public void OnItemSelected(AdapterView parent, View view, int position, long id) { MonthDao.UpdateByTitle((string)Singleton.Instance.MonthSpinner.SelectedItem); for (int i = 0; i < 28; i++) { GoalContext goalContext = GoalContextDao.GetGoalContext(i); if (goalContext.IsViewCreated) { goalContext.UpdateTextView(); } else { break; } } }
public GoalsController(GoalContext context) { _context = context; if (_context.Goals.Count() == 0) { // Create a new Goal if collection is empty, // which means you can't delete all Goals. _context.Goals.Add( new Goal { Name = "First Goal", Amount = 1.00, Description = "This is your first goal!" } ); _context.SaveChanges(); } }
public async Task TestMethod_UsingSqliteInMemoryProvider_Success() { using (var connection = new SqliteConnection("DataSource=:memory:")) { connection.Open(); var options = new DbContextOptionsBuilder <GoalContext>() .UseSqlite(connection) // Set the connection explicitly, so it won't be closed automatically by EF .Options; // Create the dabase schema // You can use MigrateAsync if you use Migrations using (var context = new GoalContext(options)) { await context.Database.EnsureCreatedAsync(); } // The connection is not closed, so the database still exists using (var context = new GoalContext(options)) { Goal goal = new Goal(); goal.Name = "test goal"; goal.Id = 1; //var user = new User() { Email = "*****@*****.**" }; context.Goals.Add(goal); await context.SaveChangesAsync(); } using (var context = new GoalContext(options)) { var count = await context.Goals.CountAsync(); Assert.Equal(1, count); var u = await context.Goals.FirstOrDefaultAsync(user => user.Name == "test goal"); Assert.NotNull(u); } } }
public static bool UpdateGoal(int id) { if (id <= 0) { return(false); } using (var db = new GoalContext()) { var goal = db.Goals.Where(x => x.ID == id).FirstOrDefault(); var oldGoal = db.Goals.Where(x => x.ID == goal.ID).FirstOrDefault(); if (oldGoal == null) { return(false); } oldGoal = goal; db.Goals.Update(oldGoal); db.SaveChanges(); return(true); } }
public GoalsController(GoalContext context) { _context = context; }
public GoalController(GoalContext goalContext) { _goalContext = goalContext; }
public BoardController(GoalContext goalContext) { _goalContext = goalContext; }