public ActionResult OutstandingRepairs(int PropID = 0)
 {
     if (Session["CustomerID"] != null && (int)Session["CustomerID"] != 0)
     {
         RepairsMaintenanceViewModel vm = new RepairsMaintenanceViewModel();
         if (Session["SelectedPropertyID"] != null)
         {
             if (PropID != 0 && Session["SelectedPropertyID"] != null)
             {
                 Session["SelectedPropertyID"] = PropID;
                 Session["SelectedProperty"]   = Models.PropertyMethods.PropertyAddress(PropID);
                 Session["IsDirector"]         = EstateDirectors.EstateDirectorMethods.IsCustomerDirector(GlobalVariables.GetConnection(), PropID).ToString();
                 //Models.GlobalVariables.SelectedProperty = Models.PropertyMethods.PropertyAddress(PropID);
                 Estates e = EstateMethods.GetEstatedByUnitID((int)Session["SelectedPropertyID"]);
                 Session["EstateName"] = e.EstateName;
                 e = null;
             }
             if ((int)Session["SelectedPropertyID"] == 0)
             {
                 vm.PropListViewModel = new ServiceChargeBudgetViewModel();
                 vm.PropListViewModel.PropertyList   = Models.PropertyMethods.GetAllOwnedProperties((int)Session["CustomerID"]);
                 vm.PropListViewModel.ControllerName = "RepairsMaintenance";
                 vm.PropListViewModel.ViewName       = "OutstandingRepairs";
             }
             else
             {
                 Estates Estate = new Estates();
                 Estate                = EstateMethods.GetEstatedByUnitID((int)Session["SelectedPropertyID"]);
                 vm.Repair             = RepairMethods.GetOutstandingRepairs(Estate.EstatedID);
                 Session["EstateName"] = Estate.EstateName;
             }
         }
         else
         {
             Estates Estate = new Estates();
             Estate                = EstateMethods.GetEstatedByUnitID((int)Session["SelectedPropertyID"]);
             vm.Repair             = RepairMethods.GetOutstandingRepairs(Estate.EstatedID);
             Session["EstateName"] = Estate.EstateName;
         }
         return(View("OutstandingRepairs", vm));
     }
     else
     {
         //return not logged in view
         return(View("../Home/NotLoggedIn"));
     }
 }
        public ActionResult RepairDetail(int repairID, string updateConfirmation = "")
        {
            if (Session["CustomerID"] != null)
            {
                RepairID = repairID;

                vm        = new RepairsMaintenanceViewModel();
                vm.Repair = new Repairs();

                vm.Repair = RepairMethods.GetAllRepairDetails(repairID);
                vm.Repair.RepairHistory = new List <Repairs>();

                //gets call reports
                vm.CallReports = RepairMethods.GetRepairReport(repairID);

                //gets service charge budget and expediture
                vm.ServiceChargeInfo = EstateMethods.GetExpenditurebyPO(vm.Repair.PONumber);

                //Gets contractor name
                vm.ContractorInfo = ContractorMethods.ContractorDetailsByPO(vm.Repair.PONumber);

                //Gets completion cost
                if (vm.Repair.Status == "Completed")
                {
                    vm.Repair.completionCost    = RepairMethods.CompletedCost(vm.Repair.PONumber);
                    vm.Repair.completionCostStr = Controls.CurrencyString(vm.Repair.completionCost);
                }

                //Repair Updates
                vm.Repair.AutomaticUpdates     = Models.RepairUpdateMethods.IsCustomerRegisteredForUpdates(repairID, (int)Session["CustomerID"]);
                vm.AutomaticUpdateConfirmation = updateConfirmation;
                //gets repair history
                vm.Repair.RepairHistory = RepairMethods.GetRepairHistory(repairID);
                vm.Repair.ID            = repairID;
                return(View(vm));
            }
            else
            {
                //return not logged in view
                return(View("../Home/NotLoggedIn"));
            }
        }