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)); }