public async Task<IActionResult> Create([Bind("DeviceType,NameTag,Assignee,Domain,EntryDate,Brand,Model,Serial,OS,CPU,ProcessorSpeed,RAM,DriveSize,HardDriveType,Optical,ScreenSize,User,Pwd,Retired,Notes")] Devices devices) // removed , string[] selectedDeviceSpecs from the end { if (ModelState.IsValid) { _context.Add(devices); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(devices); }
public async Task <IActionResult> Create([Bind("CurrentStatusID,ApprovalStatus,RentalsID,RowVersion")] CurrentStatus currentStatus) { if (ModelState.IsValid) { _context.Add(currentStatus); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DevicesID"] = new SelectList(_context.Devices, "DevicesID", "Assignee", currentStatus.RentalsID); return(View(currentStatus)); }
public async Task <IActionResult> Create([Bind("RentalsID,RenterName,BeginRental,EndRental,ApprovedBy,Info,DevicesID,CurrentStatusID")] Rentals rentals) { try { if (ModelState.IsValid) { _context.Add(rentals); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } PopulateDeviceDropDownList(rentals.DevicesID); PopulateCurrentStatusDropDownList(rentals.CurrentStatusID); return(View(rentals)); }