private ActionResult CorItemShort(int?id) //cor item id
        {
            var item = db.GetCorItemInfoByCorItemID(id).FirstOrDefault();

            if (item == null)
            {
                return(HttpNotFound());
            }

            int?corID = 0, projectItemID = 0;
            var corItem = db.ProjectCorItems.Where(p => p.CorItemID == id).Select(p => new { p.CorID, p.ItemID }).FirstOrDefault();

            if (corItem != null)
            {
                corID         = corItem.CorID;
                projectItemID = corItem.ItemID;
            }

            var projectID = db.ProjectCor.Where(p => p.CorID == corID).Select(p => p.ProjectID).FirstOrDefault();

            ViewBag.Areas         = new SelectList(db.GetAreasByProjectID(projectID).ToList(), nameof(GetAreasByProjectID_Result.ViewID), nameof(GetAreasByProjectID_Result.Division), item.AreaID);
            ViewBag.Divisions     = new SelectList(db.GetDivisionsByProjectID(projectID).ToList(), nameof(GetDivisionsByProjectID_Result.ViewID), nameof(GetDivisionsByProjectID_Result.Division), item.DivisionID);
            ViewBag.ProjectStages = new SelectList(db.GetProjectStagesByProjectID(projectID).ToList(), nameof(GetProjectStagesByProjectID_Result.ProjectStageID), nameof(GetProjectStagesByProjectID_Result.StageName), item.StageID);
            ViewBag.ProjectID     = projectID;
            ViewBag.ProjectItemID = projectItemID;
            ViewBag.IsCorItem     = true;

            var priceModel = new Models.ItemModels.EditShortItem.PriceModel()
            {
                ItemID        = id,
                Qty           = item.Qty,
                UnitCost      = item.UnitCost,
                UnitPrice     = item.UnitPrice,
                Extension     = item.Extension,
                Margin        = item.Margin,
                Markup        = item.Markup,
                Tax           = item.Tax,
                Taxable       = item.Taxable ?? false,
                Total         = item.Total,
                ExcludePOR    = item.ExcludePor ?? false,
                WarranteePart = item.WarranteePart ?? false,
                OneOffItem    = item.OneOffItem ?? false
            };

            var itemDetails = new ItemModels.ItemDetails()
            {
                ViewID             = item.ViewID,
                Label              = item.Label,
                ProductDescription = item.ProductDescription,
                SalesDescription   = item.SalesDescription,
                AreaID             = item.AreaID,
                Area              = item.Area,
                DivisionID        = item.DivisionID,
                Division          = item.Division,
                Por_              = item.Por_,
                CustodyID         = item.CustodyID,
                Custody           = item.Custody,
                Qty               = item.Qty,
                ProjectCostCodeID = item.ProjectCostCodeID,
                CostCode          = item.CostCode,
                UnitCost          = item.UnitCost,
                UnitPrice         = item.UnitPrice,
                Extension         = item.Extension,
                Margin            = item.Margin,
                Markup            = item.Markup,
                Tax               = item.Tax,
                TaxRate           = 0,
                Taxable           = item.Taxable,
                Total             = item.Total,
                ExcludePor        = item.ExcludePor,
                WarranteePart     = item.WarranteePart,
                OneOffItem        = item.OneOffItem,
                StageID           = item.StageID,
                Stage             = item.Stage,
                Hours             = item.Hours,
                ProjectTotalHours = item.ProjectTotalHours
            };

            ViewBag.Item = itemDetails;

            var model = new Models.ItemModels.EditShortItem()
            {
                Price = priceModel
            };

            return(View("short", model));
        }
        // GET: Common/Items/Short - this displays Items within a Project
        public ActionResult Short(int?id, int IsCorItem = 0)
        {
            if (IsCorItem == 1)
            {
                return(CorItemShort(id));
            }

            var item = db.GetProjectItemInfoByItemID(id).FirstOrDefault();

            if (item == null)
            {
                return(HttpNotFound());
            }

            var projectID     = db.ProjectItems.Where(p => p.ItemID == id).Select(p => p.ProjectID).FirstOrDefault();
            var masterStageID = db.ProjectStages.Where(p => p.ProjectStageID == item.StageID).Select(p => p.StageMasterID).FirstOrDefault();

            ViewBag.Areas         = new SelectList(db.GetAreasByProjectID(projectID).ToList(), nameof(GetAreasByProjectID_Result.ViewID), nameof(GetAreasByProjectID_Result.Division), item.AreaID);
            ViewBag.Divisions     = new SelectList(db.GetDivisionsByProjectID(projectID).ToList(), nameof(GetDivisionsByProjectID_Result.ViewID), nameof(GetDivisionsByProjectID_Result.Division), item.DivisionID);
            ViewBag.CoStages      = new SelectList(db.GetMasterStagesBySiteID(siteusercompanyid).ToList(), nameof(GetMasterStagesBySiteID_Result.ViewID), nameof(GetMasterStagesBySiteID_Result.Stage));
            ViewBag.ProjectStages = new SelectList(db.GetProjectStagesByProjectID(projectID).ToList(), nameof(GetProjectStagesByProjectID_Result.ProjectStageID), nameof(GetProjectStagesByProjectID_Result.StageName), item.StageID);
            ViewBag.ProjectID     = repo.GetProjectIDByItemID(id ?? 0);

            var priceModel = new Models.ItemModels.EditShortItem.PriceModel()
            {
                ItemID        = id,
                Qty           = item.Qty,
                UnitCost      = item.UnitCost,
                UnitPrice     = item.UnitPrice,
                Extension     = item.Extension,
                Margin        = item.Margin,
                Markup        = item.Markup,
                Tax           = item.Tax,
                Taxable       = item.Taxable ?? false,
                Total         = item.Total,
                ExcludePOR    = item.ExcludePor ?? false,
                WarranteePart = item.WarranteePart ?? false,
                OneOffItem    = item.OneOffItem ?? false
            };

            var itemDetails = new ItemModels.ItemDetails()
            {
                ViewID             = item.ViewID,
                Label              = item.Label,
                ProductDescription = item.ProductDescription,
                SalesDescription   = item.SalesDescription,
                AreaID             = item.AreaID,
                Area              = item.Area,
                DivisionID        = item.DivisionID,
                Division          = item.Division,
                Por_              = item.Por_,
                CustodyID         = item.CustodyID,
                Custody           = item.Custody,
                Qty               = item.Qty,
                ProjectCostCodeID = item.ProjectCostCodeID,
                CostCode          = item.CostCode,
                UnitCost          = item.UnitCost,
                UnitPrice         = item.UnitPrice,
                Extension         = item.Extension,
                Margin            = item.Margin,
                Markup            = item.Markup,
                Tax               = item.Tax,
                TaxRate           = item.TaxRate,
                Taxable           = item.Taxable,
                Total             = item.Total,
                ExcludePor        = item.ExcludePor,
                WarranteePart     = item.WarranteePart,
                OneOffItem        = item.OneOffItem,
                StageID           = item.StageID,
                Stage             = item.Stage,
                Hours             = item.Hours,
                ProjectTotalHours = item.ProjectTotalHours,
            };

            ViewBag.Item = itemDetails;

            var model = new Models.ItemModels.EditShortItem()
            {
                Price = priceModel
            };

            var subLabors = db.GetSubLaborInfoByProjectItemID(id, projectID, masterStageID).ToList();
            var Labors    = new StageModels.StageMasterEdit();

            if (subLabors != null)
            {
                foreach (var sub in subLabors)
                {
                    Labors.StageSubDetails.Add(new StageModels.StageDetails()
                    {
                        StageMasterID = (int)masterStageID,
                        SubStageID    = sub.ViewID,
                        SubName       = sub.SubName,
                        CostPerHour   = sub.LaborCost,
                        PricePerHour  = sub.LaborPrice,
                        Percent       = sub.LaborFactor,
                        SellPerHour   = sub.SellPrice
                    });
                }
            }
            ViewBag.Labors = Labors;

            return(View(model));
        }