private static CalculatorDBContext GetContext() { var options = new DbContextOptionsBuilder <CalculatorDBContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new CalculatorDBContext(options); context.User.Add(new User { Id = 1, FirstName = "Simon ", LastName = "Thompson ", Email = "*****@*****.**" }); context.User.Add(new User { Id = 2, FirstName = "Stephanie", LastName = "Gibbens", Email = "*****@*****.**" }); context.SaveChanges(); return(context); }
public ActionResult AddCalc(float Operand1, float Operand2, string Operator, float Result) { try { Calculator calcObj = new Calculator(); calcObj.Operand1 = Operand1; calcObj.Operand2 = Operand2; calcObj.Operator = Operator; calcObj.Result = Result; db.Calculator.Add(calcObj); db.SaveChanges(); } catch (Exception ex) { return(Content("Error occured " + ex)); } return(RedirectToAction("CalcPartial")); }