Пример #1
0
        private void SetImageAndDescriptionState()
        {
            BookingState state = _currentBooking.State;

            switch (state)
            {
            case BookingState.NotConfirmed:
                pictureEdit1.Image       = imageCollection1.Images[1];
                lblstateDescription.Text = "Prenotazione non confermata";
                break;

            case BookingState.ConfirmedWithAccont:
                pictureEdit1.Image       = imageCollection1.Images[5];
                lblstateDescription.Text = "Prenotazione confermata";
                break;

            case BookingState.ConfimedWithoutAccount:
                pictureEdit1.Image       = imageCollection1.Images[4];
                lblstateDescription.Text = "Prenotazione confermata senza acconto";
                break;

            case BookingState.Closed:
                pictureEdit1.Image       = imageCollection1.Images[0];
                lblstateDescription.Text = "Prenotazione conclusa";
                break;

            default:
                break;
            }
        }
Пример #2
0
        private int SelectImage(Assignment a)
        {
            BookingState state = a.Booking.State;

            switch (state)
            {
            case BookingState.NotConfirmed:
                return(1);


            case BookingState.ConfirmedWithAccont:
                return(5);


            case BookingState.ConfimedWithoutAccount:
                return(4);


            case BookingState.Closed:
                return(0);


            default:
                return(0);
            }
        }
Пример #3
0
        private Image SelectImage(Assignment a)
        {
            BookingState state = a.Booking.State;

            switch (state)
            {
            case BookingState.NotConfirmed:
                return(imageCollection1.Images[1]);


            case BookingState.ConfirmedWithAccont:
                return(imageCollection1.Images[5]);


            case BookingState.ConfimedWithoutAccount:
                return(imageCollection1.Images[4]);


            case BookingState.Closed:
                return(imageCollection1.Images[0]);


            default:
                return(null);
            }
        }
Пример #4
0
        public static IEnumerable <BookingState> getPossibleSates(BookingState currentState)
        {
            switch (currentState)
            {
            case BookingState.PENDING:
                return(new List <BookingState>()
                {
                    BookingState.PENDING, BookingState.BOOKED, BookingState.DECLINED
                });

            case BookingState.BOOKED:
                return(new List <BookingState>()
                {
                    BookingState.BOOKED, BookingState.IN_PROGRESS, BookingState.DECLINED
                });

            case BookingState.IN_PROGRESS:
                return(new List <BookingState>()
                {
                    BookingState.IN_PROGRESS, BookingState.CLOSED
                });

            default:
                return(new List <BookingState>());
            }
        }
        private SolidColorBrush UpdateState(BookingState state)
        {
            var actualColor = new SolidColorBrush(Colors.White);

            switch (state)
            {
            case BookingState.Reserved:
                actualColor.Color = Colors.DarkRed;
                break;

            case BookingState.AwaitingApproval:
                actualColor.Color = Colors.DeepPink;
                break;

            case BookingState.Cancelled:
                actualColor.Color = Colors.Yellow;
                break;

            default:
                actualColor.Color = Colors.White;
                break;
            }

            return(actualColor);
        }
Пример #6
0
        public BookingState Create(BookingState bookingState)
        {
            var booking = BookingRepository.Get(bookingState.Booking.Id);

            if (booking == null)
            {
                throw new NotFoundException("BookingId");
            }

            bookingState.Booking = booking;
            BookingStateRepository.Add(bookingState);
            BookingStateRepository.Save();
            return(bookingState);
        }
Пример #7
0
        public ActionResult Edit(int id, BookingState state)
        {
            Booking booking = db.Bookings.Find(id);

            if (booking == null)
            {
                return(RedirectToAction("Index"));
            }
            booking.State           = state;
            booking.Employee        = db.Users.Find(User.Identity.GetUserId());
            db.Entry(booking).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #8
0
        public void TestInitialize()
        {
            var lodging = new Lodging()
            {
                Id          = 1,
                Name        = "Name",
                Description = "Description",
                Rating      = 3,
                IsFull      = true,
                Images      = new List <LodgingImage>()
                {
                    new LodgingImage()
                },
                PricePerNight       = 100,
                Address             = "Valid Address 123",
                Phone               = "+598 98 303 040",
                ConfirmationMessage = "Your reservation has been confirmed!",
                TouristSpot         = null
            };

            var tourist = new Tourist()
            {
                Name     = "aName",
                LastName = "aLastName",
                Email    = "*****@*****.**"
            };

            var booking = new Booking()
            {
                Id       = 1,
                CheckIn  = DateTime.Now,
                CheckOut = DateTime.Now.AddDays(5),
                Lodging  = lodging,
                Guests   = 3,
                Tourist  = tourist,
            };

            BookingState = new BookingState
            {
                Id          = 1,
                Booking     = booking,
                BookingId   = booking.Id,
                State       = "Aceptada",
                Description = "Primer estado"
            };

            BookingStateBasicInfoModel = new BookingStateBasicInfoModel(BookingState);
        }
Пример #9
0
 /// <summary>
 /// Booking class constructor.
 /// </summary>
 /// <param name="inBookingID"></param>
 /// <param name="inPerformance"></param>
 /// <param name="inListOfBookedSeats"></param>
 /// <param name="inBookingState"></param>
 /// <param name="inCustomer"></param>
 /// <param name="inIsPaid"></param>
 public Booking(
     int inBookingID,
     Performance inPerformance,
     List <Seat> inListOfBookedSeats,
     BookingState inBookingState,
     Customer inCustomer,
     bool inIsPaid, int inPrice)
 {
     bookingID         = inBookingID;
     performance       = inPerformance;
     listOfBookedSeats = inListOfBookedSeats;
     bookingState      = inBookingState;
     customer          = inCustomer;
     isPaid            = inIsPaid;
     price             = inPrice;
 }
Пример #10
0
        public static Booking Bookings_Get(int id)
        {
            string           sql    = "SELECT * FROM Bookings WHERE Booking_id = '" + id + "';";
            SQLiteDataReader reader = DBManager.DoQuery_Read(sql);

            reader.Read();

            int          bookingID    = (int)(Int64)reader["Booking_id"];
            Performance  performance  = Performances_Get((int)(Int64)reader["Performance_id"]);
            List <Seat>  seats        = Seats_GetReserved(bookingID).ToList <Seat>();
            BookingState bookingState = (BookingState)(int)(Int64)reader["Booking_state"];
            Customer     customer     = Manager.Customer_Get((int)(Int64)reader["Customer_id"]);
            bool         isPaid       = (bool)reader["isPaid"];
            int          price        = (int)(Int64)reader["Price"];

            return(new Booking(bookingID, performance, seats, bookingState, customer, isPaid, price));
        }
Пример #11
0
        public CourseSelectModel GetCourseSelectModel(Guid id, string userId)
        {
            var model = new CourseSelectModel();

            var summary = GetCourseSummary(id);

            model.Summary = summary;

            if (!string.IsNullOrEmpty(userId))
            {
                var studentService = new StudentService(Db);
                var student        = studentService.GetCurrentStudent(userId);

                var subscriptionService = new SubscriptionService(Db);
                var subscription        = subscriptionService.GetSubscription(summary.Course.Occurrence.Id, userId);

                var bookingService = new BookingService(Db);
                var bookingLists   = bookingService.GetBookingLists(summary.Course.Occurrence.Id);

                var bookingState = new BookingState();
                bookingState.Occurrence   = summary.Course.Occurrence;
                bookingState.Student      = student;
                bookingState.BookingLists = bookingLists;
                bookingState.Init();

                if (summary.Course.Dates.Any())
                {
                    var firstDate  = summary.Course.Dates.Min(x => x.Begin);
                    var lastDate   = summary.Course.Dates.Max(x => x.End);
                    var activities = Db.Activities.OfType <Course>()
                                     .Where(x => x.Occurrence.Subscriptions.Any(s => s.UserId.Equals(userId)) &&
                                            x.Dates.Any(d => d.End >= firstDate && d.Begin <= lastDate)
                                            ).ToList();

                    model.Summary.ConflictingDates = GetConflictingDates(summary.Course, activities);
                }

                model.Student      = student;
                model.BookingState = bookingState;
                model.Subscription = subscription;

                summary.Subscription = subscription;
            }

            return(model);
        }
        private Rectangle DrawSeat(BookingState state)
        {
            var rect = new Rectangle
            {
                Width           = 10,
                Height          = 10,
                Fill            = new SolidColorBrush(Colors.White),
                RadiusX         = 1.5,
                RadiusY         = 1.5,
                Stroke          = new SolidColorBrush(Colors.Black),
                StrokeThickness = 0.1
            };

            rect.Fill       = UpdateState(state);
            rect.MouseDown += DetectSeat;

            return(rect);
        }
Пример #13
0
        public async Task UpdateStatus(Guid id, BookingState newStatus, string declineReason)
        {
            var bookingRequest = await GetById(id);

            if (newStatus == BookingState.Approved)
            {
                var booking = BookingMapper.Map(bookingRequest);
                await _bookingRepository.Create(booking);
            }
            else
            {
                bookingRequest.DeclineReason = declineReason;
            }

            bookingRequest.Status = newStatus;

            _repository.Update(bookingRequest);
            await _context.SaveChangesAsync();
        }
        public void TestInitialize()
        {
            Booking = new Booking()
            {
                CheckIn  = DateTime.Now,
                CheckOut = DateTime.Now.AddDays(5),
                Lodging  = null,
                Guests   = 3,
                Tourist  = null,
                States   = new List <BookingState>()
            };

            BookingState = new BookingState
            {
                Id          = 1,
                Booking     = Booking,
                BookingId   = Booking.Id,
                State       = "Creada",
                Description = "Description"
            };
        }
        public void TestInitialize()
        {
            var booking = new Booking
            {
                CheckIn  = DateTime.Now,
                CheckOut = DateTime.Now.AddDays(5),
                Lodging  = null,
                Guests   = 3,
                Tourist  = null,
                States   = new List <BookingState>()
            };

            BookingState = new BookingState
            {
                Id          = 1,
                Booking     = booking,
                BookingId   = booking.Id,
                State       = "Creada",
                Description = "Description"
            };
            BookingRepositoryMock      = new Mock <IRepository <Booking> >(MockBehavior.Strict);
            BookingStateRepositoryMock = new Mock <IRepository <BookingState> >(MockBehavior.Strict);
        }
Пример #16
0
 public BookingStateBasicInfoModel(BookingState bookingState)
 {
     Id          = bookingState.Id;
     State       = bookingState.State;
     Description = bookingState.Description;
 }
Пример #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">Id des Kurses</param>
        /// <returns></returns>

        public PartialViewResult Subscribe(Guid id)
        {
            var logger = LogManager.GetLogger("Booking");

            var user    = GetCurrentUser();
            var student = StudentService.GetCurrentStudent(user);
            var course  = Db.Activities.OfType <Course>().SingleOrDefault(x => x.Id == id);
            OccurrenceSubscription succeedingSubscription = null;

            Occurrence             occ          = course.Occurrence;
            OccurrenceSubscription subscription = null;

            using (var transaction = Db.Database.BeginTransaction())
            {
                subscription = occ.Subscriptions.FirstOrDefault(x => x.UserId.Equals(user.Id));

                var bookingService = new BookingService(Db);
                var bookingLists   = bookingService.GetBookingLists(occ.Id);
                var bookingState   = new BookingState
                {
                    Student      = student,
                    Occurrence   = occ,
                    BookingLists = bookingLists
                };
                bookingState.Init();

                var bookingList = bookingState.MyBookingList;

                if (subscription == null)
                {
                    // eintragen
                    // den Status aus den Buchungslisten ermitteln
                    // ermittle Buchungsliste
                    // wenn eine Liste
                    // wenn voll, dann Warteliste
                    // sonst Teilnehmer
                    // sonst
                    // Fehlermeldung an Benutzer mit Angabe des Grunds

                    if (bookingList != null)
                    {
                        subscription = new OccurrenceSubscription
                        {
                            TimeStamp     = DateTime.Now,
                            Occurrence    = occ,
                            UserId        = user.Id,
                            OnWaitingList = bookingState.AvailableSeats <= 0
                        };

                        Db.Subscriptions.Add(subscription);
                    }
                }
                else
                {
                    // austragen
                    var subscriptionService = new SubscriptionService(Db);
                    subscriptionService.DeleteSubscription(subscription);

                    // Nachrücken
                    if (bookingList != null)
                    {
                        var succBooking = bookingList.GetSucceedingBooking();
                        if (succBooking != null)
                        {
                            succBooking.Subscription.OnWaitingList = false;
                            succeedingSubscription = succBooking.Subscription;
                        }
                    }
                }

                Db.SaveChanges();
                transaction.Commit();
            }

            // Mail an Nachrücker versenden
            if (succeedingSubscription != null)
            {
                var mailService = new SubscriptionMailService();
                mailService.SendSucceedingEMail(course, succeedingSubscription);

                var subscriber = GetUser(succeedingSubscription.UserId);
                logger.InfoFormat("{0} ({1}) for [{2}]: set on participient list",
                                  course.Name, course.ShortName, subscriber.UserName);
            }

            // jetzt neu abrufen und anzeigen
            var model = GetBookingStateModel(course.Id);

            return(PartialView("_CourseSummaryBookingBox", model));
        }
Пример #18
0
        private CourseSelectModel GetBookingStateModel(Guid id)
        {
            var user = GetCurrentUser();

            var student = StudentService.GetCurrentStudent(user.Id);

            var courseService = new CourseService(Db);

            var courseSummary = courseService.GetCourseSummary(id);

            var bookingService = new BookingService(Db);

            var bookingLists = bookingService.GetBookingLists(courseSummary.Course.Occurrence.Id);

            var subscriptionService = new SubscriptionService(Db);

            var subscription = subscriptionService.GetSubscription(courseSummary.Course.Occurrence.Id, user.Id);

            // Konflikte suchen
            if (Request.IsAuthenticated)
            {
                var firstDate = courseSummary.Course.Dates.Min(x => x.Begin);
                var lastDate  = courseSummary.Course.Dates.Max(x => x.Begin);

                var activities = Db.Activities.OfType <Course>().Where(a =>
                                                                       a.Occurrence.Subscriptions.Any(u => u.UserId.Equals(user.Id)) &&
                                                                       a.Dates.Any(d => d.Begin >= firstDate && d.End <= lastDate)).ToList();

                courseSummary.ConflictingDates = courseService.GetConflictingDates(courseSummary.Course, activities);

                /*
                 * foreach (var date in courseSummary.Course.Dates)
                 * {
                 *  var conflictingActivities = activities.Where(x =>
                 *      x.Id != courseSummary.Course.Id &&
                 *      x.Dates.Any(d =>
                 *          (d.End > date.Begin && d.End <= date.End) || // Veranstaltung endet im Zeitraum
                 *          (d.Begin >= date.Begin && d.Begin < date.End) || // Veranstaltung beginnt im Zeitraum
                 *          (d.Begin <= date.Begin &&
                 *           d.End >= date.End) // Veranstaltung zieht sich über gesamten Zeitraum
                 *  )).ToList();
                 *
                 *  courseSummary.ConflictingDates[date] = new List<ActivityDate>();
                 *
                 *  foreach (var conflictingActivity in conflictingActivities)
                 *  {
                 *      var conflictingDates = conflictingActivity.Dates.Where(d =>
                 *              (d.End > date.Begin && d.End <= date.End) || // Veranstaltung endet im Zeitraum
                 *              (d.Begin >= date.Begin &&
                 *               d.Begin < date.End) || // Veranstaltung beginnt im Zeitraum
                 *              (d.Begin <= date.Begin &&
                 *               d.End >= date.End) // Veranstaltung zieht sich über gesamten Zeitraum
                 *      ).ToList();
                 *      courseSummary.ConflictingDates[date].AddRange(conflictingDates);
                 *  }
                 * }
                 */
            }

            var bookingState = new BookingState
            {
                Student      = student,
                Occurrence   = courseSummary.Course.Occurrence,
                BookingLists = bookingLists
            };

            bookingState.Init();

            var model = new CourseSelectModel
            {
                User         = user,
                Student      = student,
                Summary      = courseSummary,
                BookingState = bookingState,
                Subscription = subscription,
            };

            return(model);
        }
Пример #19
0
 public void SetBookingState(BookingState newBookingState)
 {
     this.bookingState = newBookingState;
 }
Пример #20
0
 private static void _updateTrackedBookingState(Booking trackedBooking, BookingState newBookingState, ResotelContext ctx)
 {
     ctx.Entry(trackedBooking).Property( b => b.State).EntityEntry.State = EntityState.Modified;
     ctx.Entry(trackedBooking).Property(b => b.State).EntityEntry.CurrentValues.SetValues(newBookingState);
 }
        private Rectangle DrawSeat(BookingState state)
        {
            var rect = new Rectangle
            {
                Width = 10,
                Height = 10,
                Fill = new SolidColorBrush(Colors.White),
                RadiusX = 1.5,
                RadiusY = 1.5,
                Stroke = new SolidColorBrush(Colors.Black),
                StrokeThickness = 0.1
            };

            rect.Fill = UpdateState(state);
            rect.MouseDown += DetectSeat;

            return rect;
        }
        private SolidColorBrush UpdateState(BookingState state)
        {
            var actualColor = new SolidColorBrush(Colors.White);
            switch (state)
            {
                case BookingState.Reserved:
                    actualColor.Color = Colors.DarkRed;
                    break;
                case BookingState.AwaitingApproval:
                    actualColor.Color = Colors.DeepPink;
                    break;
                case BookingState.Cancelled:
                    actualColor.Color = Colors.Yellow;
                    break;
                default:
                    actualColor.Color = Colors.White;
                    break;
            }

            return actualColor;
        }
Пример #23
0
 private static void _updateTrackedBookingState(Booking trackedBooking, BookingState newBookingState, ResotelContext ctx)
 {
     ctx.Entry(trackedBooking).Property(b => b.State).EntityEntry.State = EntityState.Modified;
     ctx.Entry(trackedBooking).Property(b => b.State).EntityEntry.CurrentValues.SetValues(newBookingState);
 }