Exemplo n.º 1
0
        public async Task <IResult <BookingViewModel> > AddAsync(BookingViewModel bookingViewModel)
        {
            var booking       = _mapper.Map <Booking>(bookingViewModel);
            var bookingResult = await _bookingService.AddAsync(booking);

            bookingViewModel = _mapper.Map <BookingViewModel>(bookingResult.Data);
            return(new SuccessResult <BookingViewModel>(bookingViewModel));
        }
        public async Task <IActionResult> AddAsync(BookingModel model)
        {
            model.Id = 0;

            var isValidModel = await _bookingService.GetByOrderedDate(model.StartDate, model.EndDate);

            if (isValidModel != null)
            {
                ModelState.AddModelError("InvalidDate", "Event was already registred between selected date, you must change your date.");
                return(BadRequest(ModelState));
            }


            var booking = await _bookingService.AddAsync(model.ToServiceModel());

            return(CreatedAtAction("getbyid", new { id = booking.Id }, booking));
        }
        public async Task <ActionResult <BookingCM> > CreateBooking([FromBody] BookingCM serviceModel)
        {
            //TODO: Implements BookingDetail.GetById(int id) does not exist, return BadRequest()
            //TODO: Implements GaleryId.GetById(int id) does not exist, return BadRequest()

            DateTime createDate = DateTime.Now;
            DateTime updateDate = DateTime.Now;

            Booking crtBooking = _mapper.Map <Booking>(serviceModel);

            try
            {
                crtBooking.CreateDate = createDate;
                crtBooking.UpdateDate = updateDate;
                crtBooking.Status     = "Mới";
                var data = new Dictionary <String, String>();
                await _service.AddAsync(crtBooking);

                await _service.Save();

                Account customerAccount = await _accountService.GetByIdAsync(crtBooking.CustomerAccountId);

                data.Add("notiType", "booking_created");
                data.Add("bookingId", crtBooking.Id.ToString());
                _ = _pushNotificationService.SendMessage(
                    "Bạn nhận được đơn hàng mới",
                    "Khách hàng: " + customerAccount.DisplayName + "\n" +
                    "Địa chỉ: " + crtBooking.EndAddress,
                    "booking_created_id_" + crtBooking.BeautyArtistAccountId,
                    data
                    );
                Console.WriteLine("abc");
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
            return(CreatedAtAction("GetBookingById", new { id = crtBooking.Id }, crtBooking));
        }
Exemplo n.º 4
0
 public async Task <IActionResult> Add([FromRoute] int meetingId, BookingDto request)
 {
     return(HandleServiceResponse(await _service.AddAsync(GetClaims(), meetingId, request)));
 }
Exemplo n.º 5
0
 public async Task <IActionResult> Post([FromBody] BLL.Models.Booking booking)
 {
     return(Ok(await _service.AddAsync(booking)));
 }