public async Task <IActionResult> Delete(string housingId) { var housing = await _housingManager.GetHousingAsync(housingId); var housingEditViewModel = new HousingViewModel() { Id = housing.Id, Place = housing.Place?.Name, Description = housing.Description, Price = housing.PricePerDay, Name = housing.Name }; return(View(housingEditViewModel)); }
public async Task <IActionResult> Reservation(ReservationsViewModel reservationsViewModel) { var housing = await _housingManager.GetHousingAsync(reservationsViewModel.Id); if (ModelState.IsValid) { var userId = await _userManager.GetUserIdByEmailAsync(User.Identity.Name); int days; var reservationDto = new ReservationDto() { CheckIn = reservationsViewModel.CheckIn, CheckOut = reservationsViewModel.CheckOut, }; if (reservationDto.CheckIn == reservationDto.CheckOut) { days = 1; } else { days = (reservationDto.CheckOut - reservationDto.CheckIn).Days; } var totalAmount = days * housing.PricePerDay; var status = await _reservationManager.ReservationAsync( housing.Id, userId, totalAmount, reservationDto.CheckIn, reservationDto.CheckOut); return(status switch { StatusConstant.Booked => RedirectToAction("Reservation"), _ => RedirectToAction("Details", "Housing", new { housingId = housing.Id, message = ErrorResource.DataNotBooked }), });