Ejemplo n.º 1
0
        public async Task <BookingDTO> PutAsync(BookingCreateDTO dto)
        {
            this.Logger.LogDebug($"{nameof(BookingCreateService)} called for room with id = {dto.RoomId}");

            return(this.Mapper.Map <BookingDTO>(
                       await this.BookingCreateService.CreateAsync(Mapper.Map <BookingUpdateModel>(dto))));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([FromBody] BookingCreateDTO item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Booking model = dtoMapper.Map <Booking>(item);

            model.Note = item.Note;
            if (!IsAdmin)
            {
                model.CreatedUserId = UserId;
            }
            else
            {
                model.CreatedUserId = item.CreatedUserId;
            }

            await bookingService.CreateAsync(model);

            return(new CreatedResult(
                       $"api/booking/{model.Id}",
                       dtoMapper.Map <BookingOwnerDTO>(await bookingService.GetAsync(model.Id))
                       ));
        }
Ejemplo n.º 3
0
        public bool CreateBooking(DateTime from, DateTime to, int bookedRoomNum, string clientTel, string bookComment)
        {
            var booking = new BookingCreateDTO
            {
                StartDate     = from.AddHours(3),
                EndDate       = to.AddHours(3),
                BookComment   = bookComment,
                BookedRoomNum = bookedRoomNum,
                ClientTel     = clientTel
            };

            var resp = Client.PostAsJsonAsync("api/bookings", booking).Result;

            return(resp.IsSuccessStatusCode);
        }
Ejemplo n.º 4
0
        public IActionResult Create([FromBody] BookingCreateDTO booking)
        {
            if (!Request.Cookies.ContainsKey("sessid"))
            {
                return(BadRequest());
            }
            var sessid   = Request.Cookies["sessid"];
            var persBook = _authService.GetAuthorized(sessid)?.EmplBook;

            if (persBook == null)
            {
                return(Unauthorized());
            }
            _hotelService.CreateBooking(booking, persBook);
            return(NoContent());
        }