Exemple #1
0
        public ActionResult EditRental(int rentalId)
        {
            var queryResult       = rentalService.GetSingleRentalDataModel(rentalId);
            var assignedResident  = residentService.GetSingleResident(queryResult.id_najemcy);
            var assignedResidence =
                residencesService.GetSingleResidenceByID(queryResult.id_budynku, queryResult.id_mieszkania);
            var viewModel = new RentalEditDataViewModel()
            {
                RentalId        = rentalId,
                BuildingAddress = queryResult.adres_budynku,
                ExpiringDate    = queryResult.data_zakonczenia,
                PESEL           = assignedResident.PESEL,
                RentalPrice     = queryResult.cena_miesieczna,
                ResidenceNumber = assignedResidence.numer,
                StartDate       = queryResult.data_rozpoczecia
            };

            return(View(viewModel));
        }
        public ActionResult EditResidence(int buildingId, int?residenceId = null)
        {
            var viewModel = new BuildingListViewModel()
            {
                Items    = new List <ResidenceViewModel>(),
                Building = new BuildingViewModel()
            };

            viewModel.Building.id_budynku = buildingId;
            if (residenceId != null)    //If the user edits existing residence - try to retrieve it so they can see its data.
            {
                var result    = residencesService.GetSingleResidenceByID(buildingId, (int)residenceId);
                var residence = ViewModelMapper.Mapper.Map <ResidenceViewModel>(result);
                viewModel.Items.Add(residence);
            }
            else
            {
                viewModel.Items.Add(new ResidenceViewModel());
                viewModel.Items[0].id_mieszkania = -1;  //This residence does not exist, it's just a placeholder.
            }

            return(View(viewModel));
        }