public ActionResult NewResult(Results std) { std.Date = DateTime.Now.ToString(); context.Results.Add(std); context.SaveChanges(); string message = "SUCCESS"; return(Json(new { Message = message, JsonRequestBehavior.AllowGet })); }
// method for saving results public void SaveResults(Stopwatch stopwatch) { using (var db = new ResultsContext()) { //write var timeEntry = new Time { StartTime = DateTime.Now - stopwatch.Elapsed, EndTime = DateTime.Now, TotalTime = stopwatch.Elapsed }; db.Add(timeEntry); db.SaveChanges(); } }
public void DeleteResults() { using (var db = new ResultsContext()) { Console.WriteLine("Deleting the times"); var times = db.Times .OrderBy(b => b.StartTime); foreach (var time in times) { db.Remove(time); } db.SaveChanges(); } }
public void Commit() { _resultsContext.SaveChanges(); }