Example #1
0
        public async Task <IActionResult> Create(
            [Bind("ID,OrderNumber,EmployeeID,DateOrderCreated,PartCategoryID," +
                  "PartSubCategoryID,PartName,Ui,PartQuantity,PartDocumentNumber,TrackingNumber," +
                  "Edd,OrderStatusID")] NewOrderForm newOrderForm)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(newOrderForm);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException /*ex*/)
            {
                ModelState.AddModelError("", "Unable to save changes." +
                                         "Try again, and if problem persists see system administrator.");
            }

            PopulateEmployeeDropdownList(newOrderForm.EmployeeID);
            PopulatePartCategoryDropdownList(newOrderForm.PartCategoryID);
            PopulatePartSubcategoryDropdownList(newOrderForm.PartSubCategoryID);
            PopulateOrderStatusDropdownList(newOrderForm.OrderStatusID);
            return(View(newOrderForm));
        }
        public async Task <IActionResult> Create(
            [Bind("ID,ReportRecord,AircraftID,EmployeeID,DateDiscovered," +
                  "LocationID,AtaChapterID,AtaChapterEnd,EngineStart," +
                  "BeforeTakeoff,OnTakeoffRoll,Climb,Cruise,Descent,Approach," +
                  "Landing,Rollout,Postflight,SignificantEventID,MaintenanceTypeID," +
                  "MasterWarning,MasterCaution,WarningMessage1,WarningMessage2," +
                  "AdvisoryMessage1,AdvisoryMessage2,WarningMessageOther," +
                  "DiscrepancyDescription,AoG,Rii,WorkInstructionsPlannedAction," +
                  "CorrectiveActionDescription,OpsCheckRequired,LeakCheck,EmployeeID1," +
                  "MechanicDateSigned,EmployeeID2,QaDateSigned,GovernmentOfficial," +
                  "GovOfficialDateSigned,ReferenceDocument1,ReferenceDocument2," +
                  "CustomerName,CustomerAcceptanceDate")] DiscrepancyReportC discrepancyReportC)
        {
            if (ModelState.IsValid)
            {
                _context.Add(discrepancyReportC);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            //ViewData["AircraftID"] = new SelectList(_context.Aircrafts, "ID", "ID", discrepancyReportC.AircraftID);
            //ViewData["AtaChapterID"] = new SelectList(_context.AtaChapters, "ID", "ID", discrepancyReportC.AtaChapterID);
            //ViewData["EmployeeID"] = new SelectList(_context.Employees, "ID", "ID", discrepancyReportC.EmployeeID);
            //ViewData["LocationID"] = new SelectList(_context.Locations, "ID", "ID", discrepancyReportC.LocationID);
            //ViewData["MaintenanceTypeID"] = new SelectList(_context.MaintenanceTypes, "ID", "ID", discrepancyReportC.MaintenanceTypeID);
            //ViewData["SignificantEventID"] = new SelectList(_context.SignificantEvents, "ID", "ID", discrepancyReportC.SignificantEventID);
            PopulateAircraftsDropDownList(discrepancyReportC.AircraftID);
            PopulateEmployeesDropDownList(discrepancyReportC.EmployeeID);
            PopulateLocationsDropDownList(discrepancyReportC.LocationID);
            PopulateAtaChapterDropDownList(discrepancyReportC.AtaChapterID);
            PopulateSignificantEventsDropDownList(discrepancyReportC.SignificantEventID);
            PopulateMaintenanceTypesDropDownList(discrepancyReportC.MaintenanceTypeID);
            return(View(discrepancyReportC));
        }
Example #3
0
        public async Task <IActionResult> Create(
            [Bind("ID,DiscrepancyReportCID,DateFormCreated,EmployeeID," +
                  "RemovedPartNumber1,RemovedPartSerialNumber1,NomenclaturePart1," +
                  "RemovedPartNumber2,RemovedPartSerialNumber2,NomenclaturePart2," +
                  "RemovedPartNumber3,RemovedPartSerialNumber3,NomenclaturePart3," +
                  "RemovedPartNumber4,RemovedPartSerialNumber4,NomenclaturePart4," +
                  "InstalledPartNumber1,InstalledPartSerialNumber1,InstalledPartNumber2," +
                  "InstalledPartSerialNumber2,InstalledPartNumber3,InstalledPartSerialNumber3," +
                  "InstalledPartNumber4,InstalledPartSerialNumber4," +
                  "CorrectedBy,DateCorrected,InspectedBy,DateInspected,FiledBy,DateFiled")] RemovalInstallationForm removalInstallationForm)
        {
            if (ModelState.IsValid)
            {
                _context.Add(removalInstallationForm);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            PopulateDrDropdownList(removalInstallationForm.DiscrepancyReportCID);
            PopulateEmployeeDropdownList(removalInstallationForm.EmployeeID);
            return(View(removalInstallationForm));
        }
Example #4
0
        public async Task <IActionResult> Create(
            [Bind("ID,FaaNumber,EasaNumber,TailNumber,AircraftModelID, IsNewAircraft")] Aircraft aircraft)
        {
            if (ModelState.IsValid)
            {
                // do not want to create repeated aircraft in DB
                // first check if a tail number in DB matches the tail number being created
                var doesAircraftExist = _context.Aircrafts.Where(a => a.TailNumber == aircraft.TailNumber).Count();

                // now confirm the count received from the DB call
                if (doesAircraftExist > 0 && aircraft.IsNewAircraft)
                {
                    // error message because the aircraft exists already even though the isNew check was applied
                    ModelState.AddModelError(string.Empty, "Error : Tail Number for aircraft already exists");
                }
                else
                {
                    if (doesAircraftExist == 0 && !aircraft.IsNewAircraft)
                    {
                        // error message regarding the creation of a new aircraft without the isNew check
                        ModelState.AddModelError(string.Empty, "Error : Check the 'Is New' box for new aircraft");
                    }
                    else
                    {
                        _context.Add(aircraft);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                }
                // keeping original in case this validation fails
                //_context.Add(aircraft);
                //await _context.SaveChangesAsync();
                //return RedirectToAction(nameof(Index));
            }

            PopulateAircraftModelsDropDownList(aircraft.AircraftModelID);
            return(View(aircraft));
        }