public EditParkingUserAssignment PopulateSelectLists(EditParkingUserAssignment model) { model.AssignToUser = new SelectList(_context.Set <User>(), "Id", "Email"); model.ParkingNumberToSelect = new SelectList(_context.Set <ParkingSpot>(), "ID", "SpaceNumber"); return(model); }
private EditParkingUserAssignment PopulateEditModelWithDBRecords(ParkingAndDateRelationship parkingRelationshipRecords) { var applyPartialBooking = string.IsNullOrEmpty(parkingRelationshipRecords.ParkingDetailsOnDate.Description) ? false : parkingRelationshipRecords.ParkingDetailsOnDate.ApplyPartialBooking; var model = new EditParkingUserAssignment() { AssignToUserID = parkingRelationshipRecords.AssignedToUserID, ParkingNumberID = parkingRelationshipRecords.ParkingSpot.SpaceNumber, AssingOnDate = parkingRelationshipRecords.ParkingDetailsOnDate.Date, Description = parkingRelationshipRecords.ParkingDetailsOnDate.Description, ApplyPartialBooking = parkingRelationshipRecords.ParkingDetailsOnDate.ApplyPartialBooking, StartTimeIfPartial = parkingRelationshipRecords.ParkingDetailsOnDate.StartTimeIfPartial, EndTimeIfPartial = parkingRelationshipRecords.ParkingDetailsOnDate.EndTimeIfPartial }; model = PopulateSelectLists(model); return(model); }
public async Task <IActionResult> Edit(EditParkingUserAssignment model) { if (ModelState.IsValid) { var ParkingAndDateRelationship = await _parkingManagementManager.GetByID(model.ID); ParkingAndDateRelationship.ParkingDetailsOnDate.Date = model.AssingOnDate; ParkingAndDateRelationship.ParkingDetailsOnDate.Description = model.Description; ParkingAndDateRelationship.ParkingID = model.ParkingNumberID; ParkingAndDateRelationship.AssignedToUser = null; ParkingAndDateRelationship.AssignedToUserID = model.AssignToUserID; ParkingAndDateRelationship.ParkingDetailsOnDate.ApplyPartialBooking = model.ApplyPartialBooking; ParkingAndDateRelationship.ParkingDetailsOnDate.StartTimeIfPartial = model.StartTimeIfPartial; ParkingAndDateRelationship.ParkingDetailsOnDate.EndTimeIfPartial = model.EndTimeIfPartial; await _parkingManagementManager.UpdateAndSave(ParkingAndDateRelationship); return(RedirectToAction(nameof(Index))); } model = PopulateSelectLists(model); return(View(model)); }