private void AddDepartment() { using (var db = new CompanyContext()) { var Dept = new Department() { DeptName = DeptName }; Depts.Add(Dept); db.Departments.Add(Dept); db.SaveChanges(); } }
private void DeptsListCreator(IList <Dept> list, Delegate lambdaDevice) { Depts.Clear(); foreach (var item in list) { var devices = item.Devices; var devicesCount = devices.Count(); if (lambdaDevice != null) { devicesCount = devices.Where((Func <Device, bool>)lambdaDevice).Count(); } Depts.Add(new DView(item, devicesCount, Depts.Count() + 1)); } }