public async Task <IActionResult> Edit(int id, [Bind("MaxTrailerAxles,EstInstallTime,ProductID,BrandID,ProductTypeID,ProductName,ProductDescription,VehicleModel,ProductCode,Price,InStock")] Electrical electrical)
        {
            if (id != electrical.ProductID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(electrical);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ElectricalExists(electrical.ProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandID"]       = new SelectList(_context.Brands, "BrandID", "BrandName", electrical.BrandID);
            ViewData["ProductTypeID"] = new SelectList(_context.ProductTypes, "ProductTypeID", "ProductTypeName", electrical.ProductTypeID);
            return(View(electrical));
        }
        public async Task <IActionResult> Create([Bind("MaxTrailerAxles,EstInstallTime,ProductID,BrandID,ProductTypeID,ProductName,ProductDescription,VehicleModel,ProductCode,Price,InStock")] Electrical electrical)
        {
            if (ModelState.IsValid)
            {
                _context.Add(electrical);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandID"]       = new SelectList(_context.Brands, "BrandID", "BrandName", electrical.BrandID);
            ViewData["ProductTypeID"] = new SelectList(_context.ProductTypes, "ProductTypeID", "ProductTypeName", electrical.ProductTypeID);
            return(View(electrical));
        }
Exemple #3
0
        public string InspectBuilding()
        {
            var toReturn = new StringBuilder();

            var electrical = new Electrical();
            var foundation = new Foundation();
            var plumbing   = new Plumbing();
            var roof       = new Roof();

            toReturn.AppendLine(electrical.InspectWiring());
            toReturn.AppendLine(foundation.InspectFoundation());
            toReturn.AppendLine(plumbing.InspectPlumbing());
            toReturn.AppendLine(roof.InspectRoof());

            return(toReturn.ToString());
        }
        public override void Draw(Graphics graphics)
        {
            base.Draw(graphics);

            if (IsEndTile != true)
            {
                return;
            }

            Point centerPoint = new Point(Bounds.X + Bounds.Width / 2, Bounds.Y + Bounds.Height / 2);

            Pen black = Pens.Black;

            switch (Program.puzzleType)
            {
            case Program.PuzzleType.Elec:
                graphics.DrawLine(black, centerPoint.X - 5, centerPoint.Y, centerPoint.X + 5, centerPoint.Y);

                if (Electrical.Equals(Elec.positive) == true)
                {
                    // +
                    graphics.DrawLine(black, centerPoint.X, centerPoint.Y - 5, centerPoint.X, centerPoint.Y + 5);
                }
                break;

            case Program.PuzzleType.Mech:
                if (Mechanical.Equals(Mech.jagged) == true)
                {
                    int totalSpikes = 4;
                    int spikeHeight = (Tile.size - 1) / totalSpikes;
                    int spikeWidth  = spikeHeight / 2;

                    int y = Bounds.Y;

                    for (int i = 0; i < totalSpikes; i++)
                    {
                        int x = Bounds.X + 2 + spikeHeight * i;

                        graphics.DrawLine(black, x, y, x + spikeWidth, y + spikeHeight);
                        graphics.DrawLine(black, x + spikeWidth, y + spikeHeight, x + spikeWidth * 2, y);
                    }
                }

                if (Mechanical.Equals(Mech.rounded) == true)
                {
                    int totalBumps   = 4;
                    int bumpRadius   = (Tile.size - 1) / (totalBumps * 2);
                    int bumpDiameter = 2 * bumpRadius;

                    int y = Bounds.Y - 2;

                    for (int i = 0; i < totalBumps; i++)
                    {
                        int x = Bounds.X + 2 + bumpDiameter * i + i;

                        Rectangle circle = new Rectangle(x, y, bumpDiameter, bumpDiameter);
                        graphics.DrawArc(black, circle, 0, 180);
                    }
                }

                if (Mechanical.Equals(Mech.square) == true)
                {
                    int totalMerlons = 3;
                    int merlonWidth  = (Tile.size - 1) / (totalMerlons * 2 + 1);
                    int merlonHeight = merlonWidth + 2;

                    for (int i = 0; i < totalMerlons; i++)
                    {
                        int x = Bounds.X + 2 + merlonWidth + merlonWidth * i * 2;
                        int y = Bounds.Y;
                        graphics.DrawLine(black, x, y, x, y + merlonHeight);
                        graphics.DrawLine(black, x, y + merlonHeight, x + merlonWidth, y + merlonHeight);
                        graphics.DrawLine(black, x + merlonWidth, y + merlonHeight, x + merlonWidth, y);
                    }
                }
                break;

            case Program.PuzzleType.Plm:
                if (Plumbing.Equals(Plm.none) == true)
                {
                    break;
                }

                int margin = Tile.size / 4;

                // O
                Rectangle rect = new Rectangle(Bounds.X + margin, Bounds.Y + margin, Bounds.Width - 2 * margin, Bounds.Height - 2 * margin);
                graphics.DrawEllipse(black, rect);

                if (Plumbing.Equals(Plm.closed) == true)
                {
                    // Ø
                    graphics.DrawLine(black, rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
                }
                break;
            }
        }