示例#1
0
        public async Task <ActionResult <Reservation> > Post(ReservationDTO reservationDTO)
        {
            try
            {
                Reservation reservation = new Reservation()
                {
                    Id   = reservationDTO.Id,
                    Name = reservationDTO.Name,
                    ReservationDateTime = DateTime.Parse(reservationDTO.ReservationDateTime).ToUniversalTime(),
                    Duration            = TimeSpan.Parse(reservationDTO.Duration)
                };

                if (reservation == null)
                {
                    logger.LogWarning("Request {Path} | New reservation is equal to null", this.HttpContext.Request.Path);
                    return(StatusCode(500));
                }
                else
                {
                    logger.LogDebug("Request {Path} | Creating reservation for adding to storage is successfully", this.HttpContext.Request.Path);
                }

                return(bookingService.Add(reservation));
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Request {Path} | Unexpected exception", this.HttpContext.Request.Path);
                return(StatusCode(500));
            }
        }
        public IResult <BookingViewModel> Add(BookingViewModel bookingViewModel)
        {
            var booking       = _mapper.Map <Booking>(bookingViewModel);
            var bookingResult = _bookingService.Add(booking);

            bookingViewModel = _mapper.Map <BookingViewModel>(bookingResult.Data);
            return(new SuccessResult <BookingViewModel>(bookingViewModel));
        }
示例#3
0
        public IActionResult Create([FromBody] Booking Model)
        {
            var booking = _repos.Add(Model);

            if (booking == null)
            {
                return(BadRequest(new { message = "Error Occured" }));
            }
            return(Ok(new { message = booking.ID }));
        }
示例#4
0
        public object Add(BookingViewModel model)
        {
            model = _bookingService.Add(model);

            if (model == null)
            {
                return(new ResponseDetails(false, "Could not add entry in bookings."));
            }

            return(new ResponseDetails(true, model));
        }
示例#5
0
        internal bool BookRide(string OfferID, Rider rider, int source, int destinaiton, decimal fare, byte seats)
        {
            Offer Offer = OfferServices.GetByID(OfferID);

            if (Offer == null || Offer.SeatsAvailable < seats && seats > 0)
            {
                return(false);
            }
            else
            {
                Booking ride = SetRide(rider, source, destinaiton, fare * seats, seats, Offer);
                ride = BookingServices.Create(ride);
                BookingServices.Add(ride);
                BookingServices.SaveData();
                return(true);
            }
        }
示例#6
0
        public async Task <IActionResult> Add([FromBody] BookingModel data)
        {
            var dataEntity = await _bookingService.Add(BookingMapper.Map(data));

            return(Ok(dataEntity));
        }
 public Booking Add([FromBody] Booking booking)
 {
     return(_bookingService.Add(booking));
 }
 public IActionResult Post([FromBody] Booking value)
 {
     _bookingService.Add(value);
     return(CreatedAtAction("Get", value));
 }
 public Booking Post([FromBody] Booking value)
 {
     return(bookingService.Add(value));
 }