Exemple #1
0
        public static IR2Command CreateLeaseJobCmd(int taskNumber, FilteredListVMBase listVM)
        {
            return(R2Command.Relay(() =>
            {
                Action <LeaseDTO, ITenantDBsDir> job = null;
                string desc = null;
                switch (taskNumber)
                {
                case 1: job = SetToMonthly(out desc); break;

                case 2: if (!PopUpInput.TryGetDate("Look for Balances starting from", out DateTime date))
                    {
                        break;
                    }
                    job = ForSpecificLease.FindMemosFrom(date, out desc); break;

                default: Alert.Show($"Unrecognized task number: [{taskNumber}]"); break;
                }

                Alert.Confirm($"Run “{desc}”?", async() =>
                {
                    listVM.Main.StartBeingBusy($"Running “{desc}” ...");

                    var dir = listVM.AppArgs;
                    var lse = listVM.Rows.CurrentItem?.DTO;
                    await Task.Run(() => job.Invoke(lse, dir));

                    listVM.Main.StopBeingBusy();
                    listVM.DoAfterSave.Invoke();
                });
            },
                                   CanRun(listVM), $"Run Ad Hoc command {taskNumber}"));
        }
        public static IR2Command GetRenewInactiveLeaseCmd(FilteredListVMBase listVM,
                                                          string label = "Renew Contract for this Lease")
        {
            return(LeaseCRUD1VM.NewCmd(listVM, label,
                                       listVM.AppArgs.CanAddLease(false), (lse, crud) =>
            {
                var args = crud.AppArgs;
                var inactv = lse as InactiveLeaseDTO;
                if (inactv == null)
                {
                    throw Bad.Data("Expected non-null ‹InactiveLeaseDTO›");
                }

                if (args.MarketState.IsOccupied(inactv.Stall))
                {
                    Alert.Show($"Stall [{inactv.Stall}] is currently occupied.");
                    return;
                }

                crud.TenantTemplate = inactv.Tenant.ShallowClone();
                crud.DraftBirthDate = inactv.Tenant.BirthDate;
                crud.SetPickedStall(inactv.Stall);
                crud.SetPickedStart(inactv.DeactivatedDate.AddDays(1).Date);
                crud.SetRenewedFrom(inactv);
                crud.SetProductToSell(inactv.ProductToSell);
                crud.NewRecordSaved += (s, newLse) => inactv.ForwardBalancesTo(newLse, args);
                crud.EncodeNewDraftCmd.ExecuteIfItCan();
            }));
        }
        public static IR2Command GetTerminateThisLeaseCmd(FilteredListVMBase listVM,
                                                          string label = "Terminate this Lease")
        {
            return(LeaseCRUD1VM.NewCmd(listVM, label,
                                       listVM.AppArgs.CanTerminateteLease(false), (lse, crud) =>
            {
                if (lse == null)
                {
                    return;
                }

                var resp = MessageBox.Show($"Are you sure you want to terminate the lease for {L.f} {lse}?",
                                           "   Confirm Termination", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (resp != MessageBoxResult.Yes)
                {
                    return;
                }

                if (!PopUpInput.TryGetDate($"When is the last billable day for {L.f}{lse}?",
                                           out DateTime termDate, DateTime.Now.Date))
                {
                    return;
                }

                if (!PopUpInput.TryGetString("Why are you terminating this lease?",
                                             out string reason))
                {
                    return;
                }

                listVM.AppArgs.MarketState.DeactivateLease(lse, reason, termDate);
            }));
 public static IR2Command GetEncodeNewDraftCmd(FilteredListVMBase listVM,
                                               string label = "Encode new Lease Contract")
 {
     if (!listVM.AppArgs.CanAddLease(false))
     {
         return(null);
     }
     return(LeaseCRUD1VM.NewCmd(listVM, label, true,
                                (lse, crud) => crud.EncodeNewDraftCmd.ExecuteIfItCan()));
 }
 public static IR2Command GetEditTenantInfoCmd(FilteredListVMBase listVM,
                                               string label = "Edit Tenant Info")
 {
     return(LeaseCRUD1VM.NewCmd(listVM, label,
                                listVM.AppArgs.CanEditTenantInfo(false), (lse, crud) =>
     {
         if (lse == null)
         {
             return;
         }
         crud.AllFieldsEnabled = false;
         crud.EditCurrentRecord(lse);
     }));
 }
 public static IR2Command GetAddStallToTenantCmd(FilteredListVMBase listVM,
                                                 string label = "Add another Stall to this Tenant")
 {
     return(LeaseCRUD1VM.NewCmd(listVM, label,
                                listVM.AppArgs.CanAddLease(false), (lse, crud) =>
     {
         if (lse == null)
         {
             return;
         }
         crud.TenantTemplate = lse.Tenant.ShallowClone();
         crud.DraftBirthDate = lse.Tenant.BirthDate;
         crud.EncodeNewDraftCmd.ExecuteIfItCan();
     }));
 }
Exemple #7
0
 public void OnPickedFilterIndexChanged()
 {
     PickedList = null;
     PickedList = _enlisteds[PickedFilterIndex].Invoke(AppArgs);
     PickedList.PickedSection = PickedList.Sections.FirstOrDefault();
 }
Exemple #8
0
 private static Predicate <object> CanRun(FilteredListVMBase listVM) => _
 => (listVM.Rows.CurrentItem?.DTO != null) &&
 listVM.AppArgs.CanRunAdHocTask(false);