示例#1
0
        public async Task AddSizesAsync(int DBDetailID, string DetailName)
        {
            using (DBServerContext db = new DBServerContext())
            {
                switch (DetailName)
                {
                case "Поршень":
                    db.DETAILS.Find(DBDetailID).Piston = Sizes.Dictonary().Select(x => new DBDetailsSet.DBPiston {
                        Key = x.Key, Value = x.Value
                    }).ToList();
                    break;

                case "Шатун":
                    db.DETAILS.Find(DBDetailID).Rod = Sizes.Dictonary().Select(x => new DBDetailsSet.DBRod {
                        Key = x.Key, Value = x.Value
                    }).ToList();
                    break;

                case "Гильза цилиндра":
                    db.DETAILS.Find(DBDetailID).SleeveCylinder = Sizes.Dictonary()
                                                                 .Select(x => new DBDetailsSet.DBSleeveCylinder {
                        Key = x.Key, Value = x.Value
                    }).ToList();
                    break;

                case "Крышка шатуна":
                    db.DETAILS.Find(DBDetailID).CoverRod = Sizes.Dictonary().Select(x => new DBDetailsSet.DBCoverRod {
                        Key = x.Key, Value = x.Value
                    }).ToList();
                    break;

                case "Поршневой палец":
                    db.DETAILS.Find(DBDetailID).Finger = Sizes.Dictonary().Select(x => new DBDetailsSet.DBFinger {
                        Key = x.Key, Value = x.Value
                    }).ToList();
                    break;

                case "Коленчатый вал":
                    db.DETAILS.Find(DBDetailID).Crankshaft = Sizes.Dictonary().Select(x => new DBDetailsSet.DBCrankshaft {
                        Key = x.Key, Value = x.Value
                    }).ToList();
                    break;
                }
                db.DETAILS.Find(DBDetailID).DetailCreated = new List <DBDetailsSet.DBDetail_Created> {
                    new DBDetailsSet.DBDetail_Created {
                        DetailsList = DetailName
                    }
                };
                await db.SaveChangesAsync();
            }
        }