public PartsRequestViewModel BuildPartsViewModel(JobPlanViewModel formData) { var manufacturerPart = _context.ManufacturerParts .Include(m => m.Manufacturer) .ToList(); ManufacturerPart part = null; var manufacturers = _context.Manufacturers.ToList(); List <StockRoomRequestLine> requestLines = null; if (formData != null && formData.PartsIdList != null) { part = new ManufacturerPart(); requestLines = new List <StockRoomRequestLine>(); string[] tokens = formData.PartsIdList.Split(';'); int[] partIds = Array.ConvertAll <string, int>(tokens, int.Parse); int partIdsLen = partIds.Length / 2; StockRoomRequestLine requestLine; for (int i = 0; i < partIdsLen; i++) { part = manufacturerPart.Single(m => m.Id == partIds[i]); if (part != null) { requestLine = new StockRoomRequestLine(); requestLine.ManufacturerPart = part; requestLine.Number = partIds[i + partIdsLen]; requestLine.Description = "Test" + part.Name; requestLine.Id = i; requestLines.Add(requestLine); } } } var viewModel = new PartsRequestViewModel() { RequestLines = requestLines, ManufacturerParts = manufacturerPart, Manufacturers = manufacturers, WorkOrderNumber = null, JobPlanNumber = null }; if (formData == null || formData.JobPlanId == null || formData.WorkOrderNumber == null) { return(viewModel); } viewModel.WorkOrderNumber = (int)formData.WorkOrderNumber; viewModel.Lines = formData.PartsIdList; viewModel.Notes = formData.PartNotesList; viewModel.JobPlanNumber = (int)formData.JobPlanId; return(viewModel); }
public ActionResult PartsRequest(JobPlanViewModel formData) { var manufacturerPart = _context.ManufacturerParts .Include(m => m.Manufacturer) .ToList(); ManufacturerPart part = new ManufacturerPart(); var manufacturers = _context.Manufacturers.ToList(); List <StockRoomRequestLine> requestLines = new List <StockRoomRequestLine>(); StockRoomRequestLine requestLine; string[] tokens = formData.PartsIdList.Split(';'); int[] partIds = Array.ConvertAll <string, int>(tokens, int.Parse); int planId = formData.JobPlanId; int partIdsLen = partIds.Length / 2; for (int i = 0; i < partIdsLen; i++) { part = manufacturerPart.Single(m => m.Id == partIds[i]); if (part != null) { requestLine = new StockRoomRequestLine(); requestLine.ManufacturerPart = part; requestLine.Number = partIds[i + partIdsLen]; requestLine.Description = "Test" + part.Name; requestLine.Id = i; requestLines.Add(requestLine); } } var viewModel = new PartsRequestViewModel() { RequestLines = requestLines, ManufacturerParts = manufacturerPart, WorkOrderNumber = formData.WorkOrderNumber, Manufacturers = manufacturers, Lines = formData.PartsIdList, Notes = formData.PartNotesList, JobPlanNumber = formData.JobPlanId }; return(View(viewModel)); }
public Part GetByItemNumber(string itemNumber) { var item = _inn.newItem("Part", "get"); item.setProperty("item_number", itemNumber); var bomRel = item.createRelationship("Part BOM", "get"); var bompart = bomRel.createRelatedItem("Part", "get"); var amlRel = bompart.createRelationship("Part AML", "get"); amlRel.createRelatedItem("Manufacturer Part", "get"); item = item.apply(); if (!item.isError() && !item.isEmpty()) { item.fetchRelationships("Part BOM"); var bomRelationships = item.getRelationships(); var relCount = bomRelationships.getItemCount(); var bomParts = new List <BomPart>(); for (var i = 0; i < relCount; i++) { var rel = bomRelationships.getItemByIndex(i); var relatedItem = rel.getPropertyItem("related_id"); var bomPart = new BomPart { ItemNumber = relatedItem.getProperty("item_number"), Quantity = rel.getProperty("quantity"), RefDes = rel.getProperty("reference_designator"), }; relatedItem.fetchRelationships("Part AML"); var amlRelationships = relatedItem.getRelationships(); var amlCount = amlRelationships.getItemCount(); var amlParts = new List <ManufacturerPart>(); for (var j = 0; j < amlCount; j++) { var amlRelItem = amlRelationships.getItemByIndex(j); var amlRelatedItem = amlRelItem.getPropertyItem("related_id"); var manuf = amlRelatedItem.getPropertyAttribute("manufacturer", "keyed_name"); var mfgPart = new ManufacturerPart { ItemNumber = amlRelatedItem.getProperty("item_number"), Manufacturer = manuf }; amlParts.Add(mfgPart); } bomPart.ManufacturerParts = amlParts; bomParts.Add(bomPart); } var part = new Part { Id = item.getProperty("id"), ItemNumber = item.getProperty("item_number"), Classification = item.getProperty("classification"), EhtSubclass = item.getProperty("eht_subclass"), KamThirdLevelClass = item.getProperty("kam_3rd_level_class"), Name = item.getProperty("name"), KamDescription2 = item.getProperty("kam_description_2"), MajorRev = item.getProperty("major_rev"), MinorRev = item.getProperty("minor_rev"), ReleaseDate = item.getProperty("release_date"), EhtProduction = item.getProperty("eht_production_lc_state"), KamItemType = item.getProperty("kam_item_type"), KamKsup = item.getProperty("kam_ksup"), KamLotSerialControl = item.getProperty("kam_lot_serial_ctrl"), KamPm = item.getProperty("kam_purchased_or_manufactured"), KamProdLine = item.getProperty("kam_prodline"), KamUom = item.getProperty("kam_uom"), BomParts = bomParts }; return(part); } return(null); }