/// <summary>
 /// Creates a new instance of <see cref="ValuesController"/>.
 /// </summary>
 public ValuesController()
 {
     if (_context == null || !_context.Triangles.Any())
     {
         _context = SeedData.SetUpTriangles();
     }
 }
Beispiel #2
0
        public TriangleController(TriangleContext context)
        {
            _context = context;

            if (_context.Triangles.Count() == 0)
            {
                // Create a new Triangle if collection is empty,
                // which means you can't delete all Triangle.
                _context.Triangles.Add(new Triangle {
                    TriangleLocation = "None", X1 = 0, X2 = 0, X3 = 0, Y1 = 0, Y2 = 0, Y3 = 0
                });
                _context.SaveChanges();
            }
        }
Beispiel #3
0
        public TriangleController(TriangleContext context)
        {
            _context = context;

            if (_context.TriangleItems.Count() == 0)
            {
                foreach (var value in Enum.GetValues(typeof(RowEnum)))
                {
                    string rowName = value.ToString();
                    int    iRow    = RowAsInt(rowName) - 1; // adjust for zero based
                    for (int iCol = 0; iCol <= MAX_COL_INDEX; iCol++)
                    {
                        Triangle t = TriangleFromRowColIndex(iRow, iCol, rowName + (iCol + 1));
                        _context.TriangleItems.Add(t);
                    }
                }
                _context.SaveChanges();
            }
        }
Beispiel #4
0
 public HomeController(TriangleContext context)
 {
     db = context;
 }
Beispiel #5
0
 public GridController(TriangleContext context)
 {
     _context = context;
 }