Exemple #1
0
        private DataLayer.SeatViewModel GetTempOrder(DataContracts.TempOrderViewModel tempOrder)
        {
            DataLayer.SeatViewModel tempOrderModel = new DataLayer.SeatViewModel();
            tempOrderModel.ScreenId      = tempOrder.ScreenId;
            tempOrderModel.ScreenClassId = tempOrder.ScreenClassId;
            tempOrderModel.MovieTimingId = tempOrder.MovieTimingId;
            tempOrderModel.VendorId      = tempOrder.VendorId;
            tempOrderModel.TicketCount   = tempOrder.TicketCount;
            tempOrderModel.IPAddress     = tempOrder.IPAddress;
            tempOrderModel.TotalAmount   = tempOrder.TotalPrice;
            tempOrderModel.TicketPrice   = tempOrder.TicketPrice;
            tempOrderModel.WebOrderId    = tempOrder.WebOrderId;
            tempOrderModel.SeatIds       = string.Join(",", tempOrder.Seats.Select(seat => seat.ID));

            return(tempOrderModel);
        }
Exemple #2
0
        public BookSeatsResponse CreateTempOrder(DataContracts.TempOrderViewModel tempOrder)
        {
            BookSeatsResponse response = new BookSeatsResponse();

            try
            {
                DataLayer.SeatViewModel tempOrderModel = GetTempOrder(tempOrder);

                var result = _seatBookingRepository.CreateTempOrder(tempOrderModel);

                if (result < 0)
                {
                    if (result == -1)
                    {
                        response.ErrorMessage = "There are no seats available in booking";
                        response.ErrorCode    = 1;

                        return(response);
                    }

                    if (result == -2)
                    {
                        response.ErrorMessage = "Requested seats are more than allowed seats per booking.";
                        response.ErrorCode    = 2;

                        return(response);
                    }

                    if (result == -3)
                    {
                        response.ErrorMessage = "Requested seats are not allocated to your vendor Id.";
                        response.ErrorCode    = 3;

                        return(response);
                    }

                    if (result == -4)
                    {
                        response.ErrorMessage = "Some of the seats or all seats already booked.";
                        response.ErrorCode    = 4;

                        return(response);
                    }
                    if (result == -101)
                    {
                        response.ErrorMessage = "Internal Server Error occured.";
                        response.ErrorCode    = -101;
                        return(response);
                    }
                }
                response.ErrorCode    = 0;
                response.tempOrderId  = result;
                response.ErrorMessage = "Seats are booked successfully.";

                return(response);
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Error occured while creating temp order for ScreenId {0}: {1}", tempOrder.ScreenId, ex);
                response.ErrorMessage = "Internal Server Error occured.";
                response.ErrorCode    = -101;

                return(response);
            }
        }