Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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));
        }