public async Task <IActionResult> Complete(ReservationDetailViewModel currentReservation) { bool isReserved; if (currentReservation.Guest.GuestId > 0) { _guestService.EditGuest(currentReservation.Guest); isReserved = _reservationService.AddReservation(currentReservation); } else { var newGuestId = _guestService.AddGuest(currentReservation.Guest); var newGuest = await _guestService.GetGuest(newGuestId); currentReservation.Guest = newGuest; isReserved = _reservationService.AddReservation(currentReservation); } if (isReserved) { //ViewBag.Message = "Reservation completed succesfully!"; ViewBag.Succes = 1; } else { ViewBag.Message = "Reservation failed!"; ViewBag.Succes = 1; } return(View(nameof(Index), await _reservationService.AllReservations())); }
public ActionResult Index(Models.Reservation model) { if (ModelState.IsValid) { DAL.Models.Reservation reservation = new DAL.Models.Reservation() { RentalStartDate = model.RentalStartDate, RentalEndDate = model.RentalEndDate, Count = model.Count, TotalCost = (decimal)Session["TotalCost"], //model.TotalCostString, nie mam pojecia dlaczego nawet w stringu niechce sie to przeslac, //bo w decimallu nie idzie bo ma problem konwertowac z przecinkiem na kropke, robie late UserId = (int)Session["UserId"], BoardGameId = model.BoardGameId, }; switch (reservationService.AddReservation(reservation)) { case ReservationServiceResponse.SuccessReservation: ModelState.Clear(); TempData["SuccessReservation"] = $"Succesfully reserved: {model.BoardGameName}."; return(RedirectToAction("Login", "Login")); case ReservationServiceResponse.NotEnoughBoardGame: ViewBag.NotEnoughBoardGameMessage = "We do not have enough board games."; return(RedirectToAction("Details", "BoardGameDetailsOffer", new { boardGameId = model.BoardGameId })); default: break; } } return(View(model)); }
public ActionResult Index(Models.Reservation model) { if (ModelState.IsValid) { DAL.Models.Reservation reservation = new DAL.Models.Reservation() { RentalStartDate = model.RentalStartDate, RentalEndDate = model.RentalEndDate, Count = model.Count, TotalCost = (decimal)Session["TotalCost"], //model.TotalCostString, nie mam pojecia dlaczego nawet w stringu niechce sie to przeslac, //bo w decimallu nie idzie bo ma problem konwertowac z przecinkiem na kropke, robie late UserId = (int)Session["UserId"], BoardGameId = model.BoardGameId, }; switch (reservationService.AddReservation(reservation)) { case ReservationServiceResponse.SuccessReservation: //string imagePath = model.ImagePath; ModelState.Clear(); //ViewBag.ImagePath = imagePath; TempData["SuccessReservation"] = $"Z powodzeniem dokonano rezerwacji: {model.BoardGameName}."; return(RedirectToAction("Login", "Login")); case ReservationServiceResponse.NotEnoughBoardGame: ViewBag.NotEnoughBoardGameMessage = "Nie posiadamy wystarczającej liczby gier."; return(RedirectToAction("Details", "BoardGameDetailsOffer", new { boardGameId = model.BoardGameId })); default: break; } } return(View(model)); }
public async Task <IActionResult> Add(AddReservationDto newReservation) { if (!ModelState.IsValid) { return(BadRequest()); } return(Ok(await _reservationService.AddReservation(newReservation))); }
public IActionResult Create(ReservationViewModel model) { if (ModelState.IsValid) { reservationService.AddReservation(model); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public ActionResult Create(ReservationCreationDTO reservationDTO) { if (ModelState.IsValid) { _reservationService.AddReservation(reservationDTO); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Preregistration(ReserveModel model) { if (ModelState.IsValid) { _reservationService.AddReservation(QsMapper.CreateMap <ReserveModel, ReservationDto>(model)); TempData["Message"] = "您的预约信息已成功提交,索子会在2到3个工作日内处理,接下来将电话邀约核实,期间请保持通讯工具畅通"; return(RedirectToAction("Preregistration")); } return(View(model)); }
/// <summary> /// Adds new reservation /// </summary> private void AddNewReservation() { //Create a New Resrvation Model ReservationModel reservationModel = this.CreateReservationModel(); //Create new IReservation object IReservation reservation = this.CreateReservation(reservationModel); //add new reservation ReservationService _reservationService.AddReservation(reservation); }
public async Task <IActionResult> Add(AddReservationDTO reservationDTO) { var reservation = _mapper.Map <Reservation>(reservationDTO); reservation.UserId = GetUserId(); var rese = await _reservationService.AddReservation(reservation); return(Ok(rese)); }
public ActionResult AddReservation(string date, string time) { DateTime dateTime = string.IsNullOrEmpty(date) ? DateTime.Today : Convert.ToDateTime(date).Date; dateTime = dateTime.AddHours(Convert.ToDouble(time)); ReservationResultModel result = _reservationService.AddReservation(Convert.ToInt32(User.Identity.GetUserId()), User.Identity.GetUserName(), dateTime); TempData["result"] = result.ResultText; return(PartialView("_ReservationList", GetReservationModel(date))); }
public IActionResult MakeReservation([FromBody] ReservationDto reservation) { try { _reservationService.AddReservation(reservation, Convert.ToInt32(User.Identity.Name)); return(Ok()); } catch (ValidationException ex) { return(BadRequest(new { message = ex.Message })); } }
public IActionResult Reservation([FromBody] MvReservation reservation) { try { int reservationId = reservationService.AddReservation(reservation); return(Ok(reservationId)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult <IReservation> AddReservation(Reservation reservation) { try { return(CreatedAtAction("AddReservation", reservationService.AddReservation(reservation))); } catch (Exception e) { //Log Error and Recover //throw; return(BadRequest(e.Message)); } }
public HttpResponseMessage AddReservation(AddReservationRequestDTO model) { try { var result = _reservationService.AddReservation(model); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception e) { _logger.Error(e, "GetDetails"); return(Request.CreateResponse(HttpStatusCode.InternalServerError, e)); } }
public ActionResult AddReservation(int bookId) { string userId = User.Identity.GetUserId(); if (reservationService.AddReservation(bookId, userId) == false) { return(View("ErrorMessage")); } else { return(RedirectToAction("Index", "Home")); } }
public async Task <IActionResult> Create(ReservationCreateInputModel model) { if (!ModelState.IsValid) { model.StartTime = DateTime.Now; return(this.View(model)); } await reservationService.AddReservation(model); return(RedirectToAction(nameof(RequestSent))); }
public async Task <IActionResult> CreateAsync(ReservationDetailViewModel reservation) { if (ModelState.IsValid) { //GuestViewModel guest = await _guestService.GetGuest(reservation.Guest.GuestId); //RoomDetailViewModel room = await _roomService.GetRoom(reservation.Rooms[0].RoomId); //reservation.Guest = guest; //reservation.Rooms.Add(room); _reservationService.AddReservation(reservation); return(RedirectToAction(nameof(Index))); } return(View(reservation)); }
public async Task <IActionResult> Add([FromBody] AddReservationDTO addedReservation) { // check if requester is trying to add a reservation for someone else if (HttpContext.GetUserIdFromToken() != addedReservation.UserId) { return(Forbid()); } // check if requester has reached the maximum number of reservations if (await _permissionService.MaxDailyReservationsReached(addedReservation.UserId, addedReservation.MarketId, addedReservation.SellerId, addedReservation.Pickup)) { return(Forbid()); } return(Ok(await _reservationService.AddReservation(await HttpContext.GetTokenAsync("access_token"), addedReservation))); }
public async Task <ActionResult> AddReservation(ReservationViewModel reservationViewModel) { var user = await _userManager.GetUserAsync(HttpContext.User); Reservation reservation = new Reservation { ReservingUserId = user.Id, ReservingUser = user, Name = reservationViewModel.Name, Start = reservationViewModel.Start, End = reservationViewModel.End, Details = reservationViewModel.Details, Color = reservationViewModel.Color.Contains("#") ? reservationViewModel.Color : $"#{reservationViewModel.Color}", }; _reservationService.AddReservation(reservation); return(RedirectToAction("Index")); }
public ActionResult Create(Models.Reservation model) { if (ModelState.IsValid) { if (!reservationService.ExistsReservation(model.ShowId, model.SeatId)) { var dbModel = new Domain.Reservation(); dbModel.InjectFrom(model); reservationService.AddReservation(dbModel /*, dbModel1*/); TempData["message"] = string.Format("{0} has been saved", model.ShowName); } else { ModelState.AddModelError("SeatId", "This seat is already booked !"); ModelState.AddModelError("ShowId", "This show is already booked !"); //Seat var seats = seatRepository.GetAll(); var seatList = seats.Select(s => new SelectListItem() { Value = s.Id.ToString(), Text = s.SeatNo.ToString() }).ToList(); //Show var shows = showRepository.GetAll(); var showList = shows.Select(s => new SelectListItem() { Value = s.Id.ToString(), Text = s.Film.Name }).ToList(); ViewBag.Seats = seatList; ViewBag.Shows = showList; return(View(model)); } return(RedirectToAction("Index")); } return(View(model)); }
public async Task<IActionResult> Create(string id, ReservationInputModel inputModel) { var room = await roomService.GetRoom<RoomViewModel>(id); if (room == null || (room?.IsTaken ?? true)) { return this.NotFound(); } var roomIsEmpty = await reservationService.AreDatesAcceptable(room.Id, inputModel.AccommodationDate, inputModel.ReleaseDate); if (!roomIsEmpty) { this.ModelState.AddModelError(nameof(inputModel.AccommodationDate), "Room is already reserved at that time"); } if (!this.ModelState.IsValid) { return this.View(await FillRoomData(inputModel, room)); } var clients = new List<ClientData>(); foreach (var client in inputModel.Clients) { clients.Add(await this.userService.CreateClient(client.Email, client.FullName, client.IsAdult)); } var user = await userManager.GetUserAsync(User); var reservation = await reservationService.AddReservation( room.Id, inputModel.AccommodationDate, inputModel.ReleaseDate, inputModel.AllInclusive, inputModel.Breakfast, clients, user); return this.RedirectToAction(nameof(Details), new { id = reservation.Id }); }
public void Post([FromBody] Reservation reservation) { var r = _mapper.Map <Reservation>(reservation); _reservationService.AddReservation(r); }
public IActionResult AddReservation([FromBody] Reservation reservation) { var result = _reservationService.AddReservation(reservation); return(Ok(result)); }
public async Task AddReservation([FromBody] ReservationDto reservationDto) { await _reservationService.AddReservation(reservationDto); }
public JsonResult Post([FromBody] Reservation newReservation) { return(new JsonResult(_reservationService.AddReservation(newReservation))); }
public async Task <IActionResult> AddReservation([FromBody] Reservation reservation) { var res = await _reservationService.AddReservation(reservation); return(Ok(res)); }
public IActionResult AddReservation([FromBody] ReservationDTO reservationDTO) { logger.LogInformation("Add reservation controller in progress"); return(Ok(reservationService.AddReservation(reservationDTO))); }
public async Task <ActionResult <ReservationDomainModel> > PostAsync([FromBody] CreateReservationModel reservationModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //PaymentResponse List <ReservationDomainModel> reservationResultList = new List <ReservationDomainModel>(); int bonusPointsToAdd = 0; foreach (Guid seatId in reservationModel.SeatIds) { bonusPointsToAdd++; ReservationDomainModel domainModel = new ReservationDomainModel { ProjectionId = reservationModel.ProjectionId, SeatId = seatId, UserId = reservationModel.UserId }; CreateReservationResultModel createReservationResultModel; try { createReservationResultModel = await _reservationService.AddReservation(domainModel); } catch (DbUpdateException e) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = e.InnerException.Message ?? e.Message, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } if (!createReservationResultModel.IsSuccessful) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = createReservationResultModel.ErrorMessage, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } reservationResultList.Add(createReservationResultModel.Reservation); } try { var bonusPointsResult = _userService.AddBonusPointsByUserId(reservationModel.UserId, bonusPointsToAdd); if (bonusPointsResult == -1 || bonusPointsToAdd < 0) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = Messages.USER_BONUSPOINTS_ERROR, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } } catch (DbUpdateException e) { ErrorResponseModel errorResponse = new ErrorResponseModel { ErrorMessage = Messages.USER_BONUSPOINTS_ERROR, StatusCode = System.Net.HttpStatusCode.BadRequest }; return(BadRequest(errorResponse)); } return(Created("reservations//", reservationResultList)); }
public async Task <ReservationDTO> AddReservation([FromBody] ReservationDTO reservationDTO) { return(await _reservationService.AddReservation(reservationDTO)); }
public override IActionResult AddReservation(Reservation reservation) { long idReservation = _reservationService.AddReservation(reservation); return(StatusCode(200, idReservation)); }