示例#1
0
 private bool ValidateReq(BookingRequest bk)
 {
     if (bk.BookingType != "" && (bk.BookingType == "Cab" || bk.BookingType == "Auto" || bk.BookingType == "Bike") && bk.Mobile.Length == 10)
     {
         return(true);
     }
     return(false);
 }
示例#2
0
        private BookingResponse Book(BookingRequest bk)
        {
            BookingResponse bkRes = new BookingResponse();

            if (ht.Count < 11)
            {
                if (!ValidateReq(bk))
                {
                    bkRes.Status            = "-1";
                    bkRes.StatusDescription = "Basic Info Not Provided";
                    bkRes.RefNum            = "-1";
                }
                else
                {
                    if (!ht.Contains(bk.Mobile))
                    {
                        bkRes.RefNum            = System.Guid.NewGuid().ToString();
                        bkRes.Status            = "1";
                        bkRes.StatusDescription = "Booking Successful";
                        ht.Add(bk.Mobile, bkRes.RefNum);
                    }
                    else
                    {
                        bkRes.Status            = "-2";
                        bkRes.StatusDescription = "Already Passenger Has Booked the service";
                    }
                }
            }
            else
            {
                bkRes.Status            = "-2";
                bkRes.StatusDescription = "Service Not Available";
                bkRes.RefNum            = "-1";
                ht.Clear();
            }
            return(bkRes);
        }
示例#3
0
 public BookingResponse BookService(BookingRequest bkReq)
 {
     return(this.Book(bkReq));
 }