Example #1
0
        public static List <BomHeader> GetBomHeaders(string number = null)
        {
            List <BomHeader> bomHeaders;

            using (var db = new LiteDatabase(WebService.DatabaseFileLocation))
            {
                if (number == null)
                {
                    bomHeaders = db.GetCollection <BomHeader>()
                                 .FindAll()
                                 .ToList();
                }
                else
                {
                    bomHeaders = db.GetCollection <BomHeader>()
                                 .Find(x => x.Number.Equals(number))
                                 .ToList();
                }

                foreach (var bomHeader in bomHeaders)
                {
                    var material = db.GetCollection <Material>()
                                   .FindOne(x => x.Number.Equals(bomHeader.Number));
                    bomHeader.Description = material.Description;
                    bomHeader.BomRows     = BomRows.GetBomRows(bomHeader.Number);
                }
            }
            return(bomHeaders);
        }
Example #2
0
        public override void Create(BomHeader entity)
        {
            BomHeaderStorage.Add(entity.Number, entity);
            var bomRows = new BomRows();

            foreach (var bomRow in entity.BomRows)
            {
                bomRows.Create(bomRow);
            }
        }
Example #3
0
        public override IEnumerable <BomHeader> Query(IExpression <BomHeader> expression)
        {
            List <BomHeader> boms = new List <BomHeader>();

            if (expression.Where.Any(b => b.PropertyName.Equals("Number")))
            {
                var number = expression.Where.FirstOrDefault(w => w.PropertyName.Equals("Number"));
                if (number != null && number.Value != number && number.Value.ToString() != "")
                {
                    if (BomHeaderStorage.TryGetValue(number.Value.ToString(), out var bom))
                    {
                        var bomRows = new BomRows();
                        bom.BomRows = bomRows.GetRowsByParentNumber(number.Value.ToString());
                        boms.Add(bom);
                    }
                }
            }
            return(boms);
        }