private DataLayer.SeatViewModel GetOrder(DataContracts.OrderViewModel order) { DataLayer.SeatViewModel orderModel = new DataLayer.SeatViewModel(); orderModel.ScreenId = order.ScreenId; orderModel.ScreenClassId = order.ScreenClassId; orderModel.MovieTimingId = order.MovieTimingId; orderModel.VendorId = order.VendorId; orderModel.TicketCount = order.TicketCount; orderModel.IPAddress = order.IPAddress; orderModel.TotalAmount = order.TotalPrice; orderModel.TicketPrice = order.TicketPrice; orderModel.WebOrderId = order.WebOrderId; orderModel.SeatIds = string.Join(",", order.Seats.Select(seat => seat.ID)); orderModel.TempOrderId = order.TempOrderId; orderModel.MobileNumber = order.MobileNumber; orderModel.ShowDate = order.ShowDate; orderModel.ShowTime = order.ShowTime; orderModel.TransactionId = order.TransactionId; orderModel.PaymentType = order.PaymentType; orderModel.PaymentConfirmationNumber = order.PaymentConfirmationNumber; return(orderModel); }
public BuySeatsResponse CreateOrder(DataContracts.OrderViewModel order) { BuySeatsResponse response = new BuySeatsResponse(); try { DataLayer.SeatViewModel orderModel = GetOrder(order); var result = _seatBookingRepository.CreateOrder(orderModel); if (result < 0) { if (result == -1) { response.ErrorMessage = "Blocked seats with this booking has been expired. Please try to book again."; 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.OrderId = result; response.ErrorMessage = "Order created successfully."; return(response); } catch (Exception ex) { Log.ErrorFormat("Error occured while creating order for ScreenId {0}, tempOrder: {1}, exception Details: {2}", order.ScreenId, order.TempOrderId, ex); response.ErrorMessage = "Internal Server Error occured."; response.ErrorCode = -101; return(response); } }