예제 #1
0
        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();
            }));
        }
예제 #2
0
        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);
            }));
예제 #3
0
 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()));
 }
예제 #4
0
 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);
     }));
 }
예제 #5
0
 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();
     }));
 }