public void BookInvalidRoomFail()
        {
            int invalidRoom = 1000;

            Assert.IsTrue(!ROOMS.Contains(invalidRoom));
            Assert.IsFalse(_bookingMgr.AddBooking("jimbob", invalidRoom, DateTime.Now));
        }
        public ActionResult Create([Bind(Include = "Id,ServiceId,VehicleId,StartTime,EndTime,Status")] BookingView booking)
        {
            List <SelectListItem> VehicleId = new List <SelectListItem>();

            foreach (var item in _vehicleManager.getVehicles(User.Identity.Name))
            {
                VehicleId.Add(new SelectListItem {
                    Text = item.Model, Value = "" + item.Id
                });
            }
            List <SelectListItem> ServiceId = new List <SelectListItem>();

            foreach (var item in _serviceManager.GetServices())
            {
                ServiceId.Add(new SelectListItem {
                    Text = item.ServiceName, Value = "" + item.Id
                });
            }
            ViewData["VehicleId"] = VehicleId;
            ViewData["ServiceId"] = ServiceId;
            if (ModelState.IsValid)
            {
                booking.UserId = _userManager.findUser(User.Identity.Name).Id;
                _bookingManager.AddBooking(User.Identity.Name, booking);
                return(RedirectToAction("Index"));
            }

            return(View(booking));
        }
Exemple #3
0
        public async Task <IActionResult> AddBooking([FromBody] Booking booking)
        {
            if (booking == null)
            {
                return(BadRequest("Invalid Model"));
            }
            if (string.IsNullOrEmpty(booking.UserID) || Guid.Empty.Equals(booking.VehicleID))
            {
                return(BadRequest("Invalid Model Data"));
            }

            return(Ok(await BookingManager.AddBooking(DbContext, booking)));
        }
        /// <summary>
        /// Action for adding contact for the booking
        /// and creates a booking
        /// </summary>
        /// <param name="bookingContact"></param>
        /// <returns></returns>
        public ActionResult AddBookingContact(BookingContact bookingContact)
        {
            int     id          = Convert.ToInt32(Session["flightId"].ToString());
            var     travelClass = (Session["travelClass"].ToString());
            decimal cost        = 0;

            foreach (var item in scheduleMgr.GetSchedule())
            {
                foreach (var a in item.flightCosts)
                {
                    if (item.FlightID == id && a.TravelClass.TravelClassId == Convert.ToInt32(Session["travelClass"].ToString()))
                    {
                        cost = a.CostPerTicket;
                    }
                }
            }

            Session["guid"] = (cost.GetHashCode()).ToString();
            string S1 = Session["guid"].ToString();

            Booking B = new Booking();

            B.BookingDate = DateTime.Now;
            B.IsCanceled  = false;
            B.TotalCost   = cost;
            B.UserName    = "******";
            //B.BookingNo = S1;
            B.BookingContact = bookingContact;
            bookingMgr.AddBooking(B);

            #region Email Service to Contact
            //string body = B.BookingDate.ToString() + B.TotalCost.ToString() + Session["fromdate"].ToString() + Session["tocity"].ToString() + "No of Passengers : " + Session["noofpeople"].ToString();
            //string emailId = bookingContact.Email;

            //EmailWCFService.SMTPMailSetup emailsetup = new EmailWCFService.SMTPMailSetup();

            //emailsetup.SendMail(emailId, "Happy Trip Ticket", body);
            #endregion

            return(RedirectToAction("Index"));
        }
Exemple #5
0
        public async Task <ActionResult <string> > Post([FromBody] RoomRequest roomRequest)
        {
            bool isAvaialble = _bookingManager.IsRoomAvailable(roomRequest.RoomNumber, roomRequest.Date);

            if (isAvaialble)
            {
                try
                {
                    await _bookingManager.AddBooking(roomRequest.Guest, roomRequest.RoomNumber, roomRequest.Date);

                    return(Ok());
                } // Send error to FE for user friendly message like Failed to Save
                catch (Exception e)
                {
                    return(BadRequest(e));
                }
            }
            else
            {
                return(BadRequest());
            }
        }
Exemple #6
0
        public IHttpActionResult Book(CommonBookingEntities objCommon, string Userid)
        {
            try
            {
                //Add Source Address To DB
                int _userId = Convert.ToInt32(Userid);
                var data    = db.UserRegistrations.Where(m => m.Id == _userId).FirstOrDefault();
                var company = db.CompanyDetails.Where(m => m.UserId == _userId).FirstOrDefault();

                SourceAddressEntities se = new SourceAddressEntities();
                se.CompanyName          = company.CompanyName;
                se.CreatedDate          = DateTime.Now;
                se.CustomerName         = data.Username;
                se.DocumentName         = objCommon.DocumentName;
                se.DocumentNumber       = objCommon.DocumentNumber;
                se.EmailId              = data.Email;
                se.IsActive             = true;
                se.Phone                = data.ContactNo;
                se.UserId               = data.Id;
                se.SourceAddress1       = objCommon.SourceAddress1;
                se.SourceAddress2       = objCommon.SourceAddress2;
                se.SourceCity           = objCommon.SourceCity;
                se.SourceState          = objCommon.SourceState;
                se.SourceCountry        = objCommon.SourceCountry;
                se.SourcePincode        = objCommon.SourcePincode;
                se.CreatedBy            = data.Id;
                se.SourceDocumentName   = objCommon.DestinationDocumentName;
                se.SourceDocumentNumber = objCommon.DestinationDocumentNumber;
                int SourceId = bookingManager.AddSourceAddress(se);

                //Add Destination Address To DB
                DestinationAddressEntities de = new DestinationAddressEntities();
                de.CompanyName         = objCommon.DestinationCompanyName;
                de.CreatedDate         = DateTime.Now;
                de.CustomerName        = data.Username;
                de.DocumentName        = objCommon.DestinationDocumentName;
                de.DocumentNumber      = objCommon.DestinationDocumentNumber;
                de.EmailId             = data.Email;
                de.IsActive            = true;
                de.Phone               = data.ContactNo;
                de.DestinationAddress1 = objCommon.DestinationAddress1;
                de.DestinationAddress2 = objCommon.DestinationAddress2;
                de.DestinationCity     = objCommon.DestinationCity;
                de.DestinationState    = objCommon.DestinationState;
                de.DestinationCountry  = objCommon.DestinationCountry;
                de.DestinationPincode  = objCommon.DestinationPincode;
                de.UpdatedDate         = DateTime.Now;
                de.UserId              = data.Id;
                de.DocumentName        = objCommon.DestinationDocumentName;
                de.DocumentNumber      = objCommon.DestinationDocumentNumber;

                int DestinationId = bookingManager.AddDestinationAddress(de);

                //Add Package Details To DB
                PackageEntities pe = new PackageEntities();
                pe.CreatedBy   = _userId;
                pe.Height      = objCommon.Height;
                pe.IsActive    = true;
                pe.Lenght      = objCommon.Lenght;
                pe.Packagename = objCommon.Packagename;
                pe.Quantity    = objCommon.Quantity;
                pe.UserId      = _userId;
                pe.Weight      = objCommon.Weight;
                pe.Width       = objCommon.Width;
                int PackageId = bookingManager.AddPackage(pe);


                //Get OfficeId


                string City = objCommon.SourceCity;
                int    OfficeId;
                int    oid          = db.Offices.Where(m => m.BranchLocation == City).Select(m => m.Id).First();
                int    OfficeUserId = db.Offices.Where(m => m.City == City).Select(m => m.UserId).FirstOrDefault();
                if (oid > 0)
                {
                    OfficeId = oid;
                }
                else
                {
                    OfficeId = 36;
                }
                //Add Booking Data To DB
                BookingEntities be = new BookingEntities();
                Helper          h1 = new Helper();
                be.Amount           = Convert.ToInt32(objCommon.Amount) / 100;
                be.CreatedBy        = _userId;
                be.CreatedDate      = DateTime.Now;
                be.DestinationId    = DestinationId;
                be.OfficeId         = OfficeId;
                be.PackageDetailsId = PackageId;
                be.PaymentType      = objCommon.PaymentType;
                be.ShipmentId       = h1.GetShipmentNumber();
                be.SourceId         = SourceId;
                be.UpdatedBy        = _userId;
                be.UpdatedDate      = DateTime.Now;
                be.Userid           = _userId;
                be.IsPickUp         = false;
                be.IsActive         = true;
                be.IsDelivered      = false;
                be.IsCurrent        = true;
                be.TransactionId    = objCommon.TransactionId;
                int BookingId = bookingManager.AddBooking(be);

                //Add Tracking Info in DB
                TrackingEntities te = new TrackingEntities();
                te.BookingId         = BookingId;
                te.CargoStatusTypeId = 1;
                te.CreatedBy         = _userId;
                te.CurrentLocation   = data.City;
                te.IsActive          = true;
                te.IsDelivered       = false;
                te.UpdatedBy         = OfficeUserId;
                te.IsCurrent         = true;
                int    TrackingId = bookingManager.AddTracking(te);
                string Message    = "Your Booking Is Done With Cargovio.in From " + se.SourceCity + " To " + de.DestinationCity + " With Shipment Id " + be.ShipmentId;
                sms.Send(data.ContactNo, Message);
                string AdminMessage = "You Receive One New Booking From" + se.SourceCity + " To " + de.DestinationCity + " With Shipment Id " + be.ShipmentId;
                sms.Send("9737920098", AdminMessage);
                var    data1         = db.UserRegistrations.Where(m => m.UserTypeId == 2 && m.OfficeId == OfficeId).FirstOrDefault();
                string CAdminMessage = "You Receive One New Booking From" + se.SourceCity + " To " + de.DestinationCity + " With Shipment Id " + be.ShipmentId;
                sms.Send(data1.ContactNo, CAdminMessage);
                return(Ok(TrackingId));
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }
        public void Check_Given_Room_IsAvailable_And_Return_True_Then_Add_Booking()
        {
            var isAvailable = _bookingManager.IsRoomAvailable(101, _today);

            _bookingManager.AddBooking("Patel", 101, _today);

            Assert.IsTrue(isAvailable);
        }
        // This event handler is fired when the submit button is clicked. It uses the data that is entered into the text boxes to create
        // a booking object and inserts it into the database.
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            if (txtDate.Text == "")
            {
                MessageBox.Show("You must fill out the date box.");
                txtDate.Focus();
                return;
            }
            try
            {
                DateTime.Parse(txtDate.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("You must enter the date in the proper format(mm/dd/yyyy).");
                txtDate.Focus();
                return;
            }

            if (txtTime.Text == "")
            {
                MessageBox.Show("You must fill out the time box.");
                txtTime.Focus();
                return;
            }
            try
            {
                DateTime.Parse(txtTime.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("You must enter the date in the proper format(HH:MM:SS am/pm).");
                txtTime.Focus();
                return;
            }
            if (txtHoursToReserve.Text == "")
            {
                MessageBox.Show("You must fill out the Hours to Reserve box");
                txtHoursToReserve.Focus();
                return;
            }
            try
            {
                int.Parse(txtHoursToReserve.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("You nust enter a whole number in the Hours to Reserve field.");
                txtHoursToReserve.Focus();
                return;
            }

            DateTime dateTime = DateTime.Parse(txtDate.Text + " " + txtTime.Text);

            try
            {
                Booking booking = new Booking()
                {
                    FacilityID        = _facility.FacilityID,
                    PersonID          = _user.PersonID,
                    ScheduledCheckOut = dateTime,
                    ScheduledCheckIn  = dateTime.AddHours(int.Parse(txtHoursToReserve.Text))
                };

                if (_bookingManager.AddBooking(booking))
                {
                    this.Close();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }