Пример #1
0
        /// <summary>
        /// Gets the add attendee to group booking page
        /// </summary>
        /// <param name="bookingId">The booking Id</param>
        /// <returns>Booking/AddAttendee/BookingId</returns>
        public ActionResult AddAttendee(Guid?bookingId)
        {
            var booking = converter.ConvertBookingFromWrapper(service.GetBooking(bookingId));

            var users = converter.ConvertUserListFromWrapper(userService.GetUsers());

            var attendees = booking.ConfirmedAttendees.Concat(booking.UnconfirmedAttendees).ToList();

            var potentialAttendees = new List <User>();

            foreach (User user in users)
            {
                var test = attendees.Where(u => u.UserId == user.UserId).FirstOrDefault();
                if (test == null)
                {
                    potentialAttendees.Add(user);
                }
            }

            var model = new UpdateBooking
            {
                Booking            = booking,
                PotentialAttendees = potentialAttendees,
            };

            return(View(model));
        }
Пример #2
0
        public async Task HandleWithValidUpdateRequestCallSaveAsExpectedResultAsync()
        {
            // Arrange
            var bookingModel = new Booking {
                Id = 299536, DropLocation = "Chennai, Chrompet"
            };

            var config = new MapperConfiguration(m => { m.CreateMap <Entities.Booking, Booking>(); m.CreateMap <Booking, Entities.Booking>(); });
            var mapper = new Mapper(config);

            var bookingEntity = new Entities.Booking {
                Id = 299536, DropLocation = "Chennai, Chrompet"
            };

            repository = new Mock <IRepository>();
            repository.Setup(m => m.Get <Entities.Booking>(It.IsAny <int>())).Returns(bookingEntity);
            repository.Setup(m => m.Update <Entities.Booking>(It.IsAny <Entities.Booking>())).Returns(bookingEntity);

            underTest = new UpdateBooking(repository.Object, mapper);
            request   = new UpdateBookingRequest(bookingModel);

            // Act
            CancellationToken cancellationToken;
            var result = await underTest.Handle(request, cancellationToken);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(bookingModel.Id, result.Id);
            Assert.Equal(bookingModel.DropLocation, result.DropLocation);
        }
        public dynamic UpdateBooking(UpdateBooking sd)
        {
            EMPLOYEEDATETIMESLOT bookingUpdate  = new EMPLOYEEDATETIMESLOT();
            EMPLOYEEDATETIMESLOT bookingUpdate2 = new EMPLOYEEDATETIMESLOT();

            try
            {
                var bookingID = db.EMPLOYEEDATETIMESLOTs.Where(vvs => vvs.EMPLOYEEDATETIMESLOTID == sd.EmployeeDateTimeSlotID).Select(hh => hh.BOOKINGID).FirstOrDefault();
                bookingUpdate                     = db.EMPLOYEEDATETIMESLOTs.Find(sd.EmployeeDateTimeSlotID);
                bookingUpdate.BOOKINGID           = null;
                bookingUpdate.EMPLOYEESLOTSTAUSID = 1;

                bookingUpdate2                     = db.EMPLOYEEDATETIMESLOTs.Find(sd.newEmployeeDateTimeSlotID);
                bookingUpdate2.BOOKINGID           = bookingID;
                bookingUpdate2.EMPLOYEESLOTSTAUSID = 2;

                db.SaveChanges();
            }
            catch (Exception e)
            {
                return(false);
            }


            //booking.BOOKINGID = getCreatedBookingID(booking.CLIENTID);
            return(true);
        }
        public ActionResult Update(int id)
        {
            //This is answer to question 3 on the midterm exam!!
            UpdateBooking viewmodel = new UpdateBooking();

            //get the booking
            //Include(booking=>booking.GroomServices) => join on the booking, bookingsxservices, services bridging table
            viewmodel.Booking =
                db.GroomBookings
                .Include(booking => booking.GroomServices)
                .FirstOrDefault(booking => booking.GroomBookingID == id);


            //get all the pets
            viewmodel.Pets = db.Pets.ToList();

            //get all the owners
            viewmodel.Owners = db.Owners.ToList();

            //get all the groomers
            viewmodel.Groomers = db.Groomers.ToList();

            //get all the services
            viewmodel.Services = db.GroomServices.ToList();


            return(View(viewmodel));
        }
        public HttpResponseMessage UpdateBooking(UpdateBooking sd)
        {
            EMPLOYEEDATETIMESLOT bookingUpdate  = new EMPLOYEEDATETIMESLOT();
            EMPLOYEEDATETIMESLOT bookingUpdate2 = new EMPLOYEEDATETIMESLOT();

            try
            {
                var bookingID = db.EMPLOYEEDATETIMESLOTs.Where(vvs => vvs.EMPLOYEEDATETIMESLOTID == sd.EmployeeDateTimeSlotID).Select(hh => hh.BOOKINGID).FirstOrDefault();
                bookingUpdate                     = db.EMPLOYEEDATETIMESLOTs.Find(sd.EmployeeDateTimeSlotID);
                bookingUpdate.BOOKINGID           = null;
                bookingUpdate.EMPLOYEESLOTSTAUSID = 1;

                bookingUpdate2                     = db.EMPLOYEEDATETIMESLOTs.Find(sd.newEmployeeDateTimeSlotID);
                bookingUpdate2.BOOKINGID           = bookingID;
                bookingUpdate2.EMPLOYEESLOTSTAUSID = 2;

                db.SaveChanges();
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest,"Error With Booking "));
            }


            //booking.BOOKINGID = getCreatedBookingID(booking.CLIENTID);
            return(Request.CreateResponse(HttpStatusCode.Created));
        }
        public ActionResult Update(int id)
        {
            UpdateBooking viewmodel = new UpdateBooking();

            viewmodel.Booking  = db.Bookings.FirstOrDefault(booking => booking.BookingID == id);
            viewmodel.Doctors  = db.Doctors.ToList();
            viewmodel.Patients = db.Patients.ToList();

            return(View(viewmodel));
        }
        //Update booking appointment
        public ActionResult Update(int id)
        {
            //This different model to fetch data from different tables
            UpdateBooking viewmodel = new UpdateBooking();

            viewmodel.Booking  = db.Bookings.FirstOrDefault(booking => booking.BookingID == id);
            viewmodel.Doctors  = db.Doctors.ToList();
            viewmodel.Patients = db.Patients.ToList();

            return(View(viewmodel));
        }
Пример #8
0
        private void HolidayUpdated(HolidayUpdatedEvent @event)
        {
            _holidayRepository.Update(@event.Source);

            var updateBookingCommand = new UpdateBooking
            {
                Id    = @event.Source.Id.Value,
                Start = @event.Source.Start,
                End   = @event.Source.End
            };

            _bus.Send(updateBookingCommand);
        }
        private void AppointmentUpdated(AppointmentUpdatedEvent @event)
        {
            _appointmentRepository.Update(@event.Source);

            //todo: still a problem here.
            //Some logic has slipped into here on how to raise a command to make a booking.
            var makeBookingCommand = new UpdateBooking
            {
                Id    = @event.Source.Id.Value,
                Start = @event.Source.Date + @event.Source.StartTime,
                End   = @event.Source.Date + @event.Source.EndTime,
            };

            _bus.Send(makeBookingCommand);
        }
        public HttpResponseMessage Updatebooking(UpdateBooking sd)
        {
            EMPLOYEEDATETIMESLOT bookingUpdate = new EMPLOYEEDATETIMESLOT();

            try
            {
                bookingUpdate                     = db.EMPLOYEEDATETIMESLOTs.Find(sd.BookingID);
                bookingUpdate.BOOKINGID           = null;
                bookingUpdate.EMPLOYEESLOTSTAUSID = 1;


                db.SaveChanges();
            }
            catch (Exception e)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Error With Booking "));
            }


            //booking.BOOKINGID = getCreatedBookingID(booking.CLIENTID);
            return(Request.CreateResponse(HttpStatusCode.Created));
        }
        public dynamic DeleteBooking(UpdateBooking sd)
        {
            EMPLOYEEDATETIMESLOT bookingUpdate = new EMPLOYEEDATETIMESLOT();

            try
            {
                bookingUpdate                     = db.EMPLOYEEDATETIMESLOTs.Find(sd.BookingID);
                bookingUpdate.BOOKINGID           = null;
                bookingUpdate.EMPLOYEESLOTSTAUSID = 1;


                db.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }


            //booking.BOOKINGID = getCreatedBookingID(booking.CLIENTID);
            return(true);
        }
Пример #12
0
 public async Task Put(string bookingOrderId, [FromBody] UpdateBooking command)
 {
     await Mediator.Send(command);
 }