Ejemplo n.º 1
0
        public void CancelReservation(Reservation reservation)
        {
            int          userId = sessMan.GetUserId();
            User         user   = Umodel.GetUserById(userId);
            bool         admin  = user.Admin;
            CancelStatus cancelStatus;

            if (admin)
            {
                cancelStatus = CancelStatus.InTime;
            }
            else
            {
                int timeTillReservation = HowLongUntil(reservation);
                cancelStatus = CancelStatusFromHours(timeTillReservation);
            }
            Cancellation cancellation = new Cancellation()
            {
                Reservation  = reservation,
                ByAdmin      = admin,
                CancelStatus = cancelStatus,
                Done         = admin,
                CancelDate   = timeManager.Now()
            };

            Cancellations.Add(cancellation);
            Reservations.SaveChanges();
        }
Ejemplo n.º 2
0
        public IList <LateCancellationInfo> GetUnhandledLateCancellations()
        {
            var list = Cancellations.Query().Where(c => !c.Done && c.CancelStatus != CancelStatus.InTime && !c.ByAdmin)
                       .OrderByDescending(c => c.Reservation.Date).ThenBy(c => c.Reservation.Timeslot.StartTime)
                       .Include(c => c.Reservation).ThenInclude(r => r.Timeslot)
                       .Include(c => c.Reservation).ThenInclude(r => r.User).ThenInclude(u => u.UserPrivacyInfo).ToList();

            return(ConvertCancellationToInfo(list));
        }
Ejemplo n.º 3
0
 public void UpdateLateCancellations(int[] ids)
 {
     foreach (int id in ids)
     {
         var cancellation = Cancellations.GetAll().Where(c => c.Id == id).FirstOrDefault();
         cancellation.Done = true;
         Cancellations.Update(cancellation);
     }
     Cancellations.SaveChanges();
 }
Ejemplo n.º 4
0
 protected override IObservable <string[]> Lookup(IObservable <string> texts) =>
 texts
 .Throttle(_throttleDueTime)                                                           // [1]
 .DistinctUntilChanged()                                                               // [2]
 .Select(text =>
         Observable.FromAsync(async ct => await SearchEngine.Search(text, ct))         // [3]
         .Timeout(_timeoutDueTime)                                                     // [4]
         .Retry(_retryCount)                                                           // [5]
         .Catch((TimeoutException ex) => Observable.Return(new[] { "<< TIMEOUT >>" })) // [6]
         .Catch((Exception ex) => Observable.Return(new[] { "<< ERROR >>" }))          // [7]
         .Amb(Cancellations.FirstAsync().Select(unit => new[] { "<< CANCEL >>" }))     // [9]
         )
 .Switch();                                                                            // [8]
Ejemplo n.º 5
0
 /// <summary>
 /// Default KPA Constructor
 /// </summary>
 public KPA()
 {
     plan                  = new Plan();
     purch                 = new Purch();
     purchSub              = new Purch_Sub();
     purchTotal            = new Purch_Total();
     purchPlanTotal        = new Purch_Plan_Total();
     followUp              = new Follow_Up();
     cancellations         = new Cancellations();
     ncrs                  = new NCRs();
     hotJobs               = new Hot_Jobs();
     excessStockStock      = new Excess_Stock_Stock();
     excessStockOpenOrders = new Excess_Stock_Open_Order();
     currPlanVsActual      = new Current_Plan_vs_Actual();
     mtc = new MTC();
 }
Ejemplo n.º 6
0
 protected override IObservable <string[]> Lookup(IObservable <string> texts) =>
 texts
 .__LOG_RAW_TEXT_FOR_DEMO()
 .Throttle(_throttleDueTime)
 .DistinctUntilChanged()
 .__LOG_TEXT_FOR_DEMO()
 .__DO_FOR_CONTROL(text => SetCancelButtonAccessibility(enable: true))
 .Select(text =>
         Observable.FromAsync(async ct => await SearchEngine.Search(text, ct))
         .__LOG_TIMEINTERVAL_FOR_DEMO($"search: {text}")
         .Timeout(_timeoutDueTime)
         .__LOG_ERROR_FOR_DEMO("RETRY")
         .Retry(_retryCount)
         .Catch((TimeoutException ex) => Observable.Return(new[] { "<< TIMEOUT >>" }).__LOG_ERROR_FOR_DEMO("TIMEOUT", ex))
         .Catch((Exception ex) => Observable.Return(new[] { "<< ERROR >>" }).__LOG_ERROR_FOR_DEMO("FATAL ERROR", ex))
         .Amb(Cancellations.FirstAsync().Select(unit => new[] { "<< CANCEL >>" }).__LOG_FOR_DEMO("CANCEL"))
         )
 .Switch()
 .__DO_FOR_CONTROL(text => SetCancelButtonAccessibility(enable: false));
Ejemplo n.º 7
0
        .Switch();                                                                            // [8]

        public override void Cancel()
        {
            Cancellations.OnNext(Unit.Default); // [9]
        }
Ejemplo n.º 8
0
 public Cancellation GetCancellationByReservationId(int resId)
 {
     return(Cancellations.GetAll().Where(c => c.ReservationId == resId).FirstOrDefault());
 }