Пример #1
0
        public ActionResult BookHaircut(
            [FromQuery] string customerId,
            [FromQuery] string barberId,
            [FromQuery] string date,
            [FromQuery] string time,
            [FromQuery] List <int> serviceIds)
        {
            DateTimeOffset dateTime = DateTimeUtil.GetTimeFrom(date, time);

            //Get services of barber
            List <BarberServices> services = _barberService.GetServicesByBarber(barberId)
                                             .Where(s => serviceIds.Contains(s.Id)).ToList();

            var booking = _bookingService.BookSlot(customerId, barberId, dateTime, services, out var rs);

            if (rs)
            {
                //Make deposit transaction
                _paymentService.MakeDeposit(
                    customerId,
                    barberId,
                    PaymentConstants.PaymentAmount.BookingDepositAmount,
                    booking.Id);

                return(new JsonResult("Booked successfully")
                {
                    StatusCode = StatusCodes.Status200OK
                });
            }

            return(new JsonResult("Fail to book")
            {
                StatusCode = StatusCodes.Status404NotFound
            });
        }
Пример #2
0
        public ActionResult MakeDeposit(string senderId, string receiverId, decimal amount, int bookingId)
        {
            bool result = _paymentMethodService.MakeDeposit(senderId, receiverId, amount, bookingId);

            if (!result)
            {
                return(new JsonResult(PaymentDescription.NotEnoughMoney_VN)
                {
                    StatusCode = StatusCodes.Status409Conflict
                });
            }
            return(new JsonResult(null)
            {
                StatusCode = StatusCodes.Status200OK
            });
        }