public Part LookupAssociatedPart(int partID)
        {
            var part = AssociatedParts.Where(p => p.PartID == partID).FirstOrDefault();

            if (part == null)
            {
                throw new Exception(message: $"A part with ID #{partID} is not associated with this product.");
            }

            return(part);
        }
示例#2
0
        public Part LookupAssociatePart(int partId)
        {
            var part = AssociatedParts.Where(x => x.PartId == partId).FirstOrDefault();

            if (part == null)
            {
                throw new Exception(message: "No matching parts could be found.");
            }

            return(part);
        }
示例#3
0
        public bool RemoveAssociatePart(int partId)
        {
            var partToRemove = AssociatedParts.Where(x => x.PartId == partId).FirstOrDefault();

            if (partToRemove == null)
            {
                return(false);
            }

            AssociatedParts.Remove(partToRemove);
            return(true);
        }