コード例 #1
0
ファイル: DataRepository.cs プロジェクト: kacper1410/TP2020_P
        public void RemoveDepartment(int id)
        {
            using (Context = new DepartmentsDataContext())
            {
                Department department = Context.Departments
                                        .Where(d => d.DepartmentID == id)
                                        .FirstOrDefault();

                Context.Departments.DeleteOnSubmit(department);

                Context.SubmitChanges();
            }
        }
コード例 #2
0
ファイル: DataRepository.cs プロジェクト: kacper1410/TP2020_P
        public void UpdateDepartment(int id, string name, string groupName)
        {
            using (Context = new DepartmentsDataContext())
            {
                Department department = Context.Departments.Single(x => x.DepartmentID == id);

                department.Name         = name;
                department.GroupName    = groupName;
                department.ModifiedDate = DateTime.Now;

                Context.SubmitChanges();
            }
        }
コード例 #3
0
ファイル: DataRepository.cs プロジェクト: kacper1410/TP2020_P
        public void AddDepartment(string name, string groupName)
        {
            Department department = new Department();

            department.Name         = name;
            department.GroupName    = groupName;
            department.ModifiedDate = DateTime.Now;

            using (Context = new DepartmentsDataContext())
            {
                Context.Departments.InsertOnSubmit(department);
                Context.SubmitChanges();
            }
        }