public PartialViewResult ApartmentDetails(int apartmentId)
        {
            Apartment            apartment = apartmentService.GetApartment(apartmentId);
            ApartmentCleaningDto dto       = new ApartmentCleaningDto();

            dto.ApartmentId = apartmentId;
            dto.Name        = apartment.Name;
            return(PartialView("_ApartmentCleaningActivity", dto));
        }
Example #2
0
        public ActionResult CloseApartmentDetails(int?id)
        {
            try
            {
                var apartment = Mapper.Map <ApartmentDTO, ApartmentViewModel>(apartmentService.GetApartment(id));

                if (apartment == null)
                {
                    return(HttpNotFound());
                }

                if (apartmentService.IsApartmentHasBookingsInFuture(id))
                {
                    ViewBag.Error = "This apartment cannot be closed because of bookings in future.";
                }

                return(PartialView(apartment));
            }
            catch (ValidationException ex)
            {
                //Log ex
            }

            return(HttpNotFound());
        }
Example #3
0
        public ActionResult RoomPickingConfirmation(int?aprtId, int?reqId)
        {
            try
            {
                var apartmentDto = apartmentService.GetApartment(aprtId.Value);

                if (apartmentDto == null)
                {
                    ViewBag.Error = "Invalid apartment id!";

                    return(View());
                }

                var apartment = Mapper.Map <ApartmentDTO, ApartmentViewModel>(apartmentDto);
                ViewBag.ReqId = reqId.Value;

                return(View(apartment));
            }
            catch (ValidationException ex)
            {
                // Залогировать эксепшн
            }

            return(RedirectToAction("RoomsForPick", new { @id = reqId }));
        }
        public ActionResult PickApartment(int?id)
        {
            try
            {
                if (id == null || BookingContainer.Date == null)
                {
                    return(View("InvalidData"));
                }

                var apartment = Mapper.Map <ApartmentDTO, ApartmentViewModel>(apartmentService.GetApartment(id));

                if (apartmentService.IsCorrectApartmentForPickedDate(id, BookingContainer.Date, BookingContainer.Days))
                {
                    bookingService.MakeBooking(new BookingDTO
                    {
                        ApartmentClassId = apartment.ApartmentClassId,
                        ApartmentId      = id.Value,
                        DateOfArrival    = BookingContainer.Date,
                        DaysOfArrival    = BookingContainer.Days,
                        UserId           = User.Identity.GetUserId()
                    });

                    return(RedirectToAction("Index"));
                }
                else
                {
                    if (apartment.ApartmentClassId == 1)
                    {
                        ViewBag.Error = "No free luxury apartments for date " + BookingContainer.Date.ToShortDateString() + " ";
                    }
                    else if (apartment.ApartmentClassId == 1)
                    {
                        ViewBag.Error = "No free comfort apartments for date " + BookingContainer.Date.ToShortDateString() + " ";
                    }
                    else if (apartment.ApartmentClassId == 1)
                    {
                        ViewBag.Error = "No free economy apartments for date " + BookingContainer.Date.ToShortDateString() + " ";
                    }

                    return(View("MakeBooking"));
                }
            }
            catch (ValidationException ex)
            {
                // Залогировать эксепшн
            }

            return(HttpNotFound());
        }