private void OnDeleteClicked(object sender, EventArgs e) { using (CalculationDbContext db = new CalculationDbContext()) { foreach (var item in View.SelectedItems) { db.DeleteBundle(item.Id); } db.SaveChanges(); } FillData(); }
public void Solve(string name, PulsationAlphaData data) { using (CalculationDbContext context = new CalculationDbContext()) { var bundle = context.GetBundle(data.GroupId); int NPeriod = bundle.PeriodN(); var grid = bundle.GetGrid(); var alphaGroup = new Bundle("Нахождение коэффициентов alpha", data); int Nt = bundle.GetCount(); context.SaveChanges(); try { IIntegrator integrator = new SimpsonIntegrator(); var lastPeriodLayers = bundle.GetArrays(Nt - NPeriod, NPeriod); int number = 0; for (int deg = 2; deg <= 3; deg++) { double[] alphaValues = new double[NPeriod]; for (int i = 0; i < NPeriod; i++) { alphaValues[i] = CalculateAlpha(integrator, deg, lastPeriodLayers[i], grid.Values, grid.h, NPeriod); } alphaGroup.AddArray(string.Format("alpha{0}", number + 1), number, alphaValues); number++; } OnSolved(true); } catch (Exception exception) { OnSolved(false, exception); } } }
public void SaveChanges() { _dbContext.SaveChanges(); }
public IActionResult Submit(PageData page, string action) { if (action == "Evaluate") { var calculation = new StringCalc(); var note = new History { Expression = page.Expression }; note.Result = calculation.DoCalculation(note.Expression).ToString(); note.Host = Request.Host.ToString(); note.CreatedDateTime = DateTime.Now; _context.Histories.Add(note); _context.SaveChanges(); page.PageNumber = 0; } var notes = _context.Histories.ToList(); if (action == "Search") { page.PreviousSearchExpression = page.NewSearchExpression; page.PreviousSearchHost = page.NewSearchHost; notes = SortedByDate(DoFilter(notes, page), page); page.Histories = notes; page.PageNumber = 0; GetAnswerFilter(page); return(View("Index", page)); } if (action == "Previous") { if (page.PageNumber <= 0) { page.PageNumber = 0; page.Histories = SortedByDate(DoFilter(notes, page).ToList(), page);; GetAnswerFilter(page); return(View("Index", page)); } else { --page.PageNumber; page.Histories = SortedByDate(DoFilter(notes, page).ToList(), page);; GetAnswerFilter(page); return(View("Index", page)); } } if (action == "Next") { if (page.PageNumber >= page.TotalPages) { page.PageNumber = page.TotalPages; page.Histories = SortedByDate(DoFilter(notes, page).ToList(), page); GetAnswerFilter(page); return(View("Index", page)); } else { ++page.PageNumber; page.Histories = SortedByDate(DoFilter(notes, page).ToList(), page); GetAnswerFilter(page); return(View("Index", page)); } } page.Histories = SortedByDate(DoFilter(notes, page).ToList(), page); return(View("Index", page)); }