コード例 #1
0
ファイル: SchoolBL.cs プロジェクト: JaySmith/Presentations
 public void DeleteDepartment(Department department)
 {
     try
     {
         schoolRepository.DeleteDepartment(department);
     }
     catch (Exception ex)
     {
         //Include catch blocks for specific exceptions first,
         //and handle or log the error as appropriate in each.
         //Include a generic catch block like this one last.
         throw ex;
     }
 }
コード例 #2
0
 public void UpdateDepartment(Department department, Department origDepartment)
 {
     try
     {
         context.Departments.Attach(origDepartment);
         context.ApplyCurrentValues("Departments", department);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         //Include catch blocks for specific exceptions first,
         //and handle or log the error as appropriate in each.
         //Include a generic catch block like this one last.
         throw ex;
     }
 }
コード例 #3
0
 public void InsertDepartment(Department department)
 {
     try
     {
         department.DepartmentID = GenerateDepartmentID();
         context.Departments.AddObject(department);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         //Include catch blocks for specific exceptions first,
         //and handle or log the error as appropriate in each.
         //Include a generic catch block like this one last.
         throw ex;
     }
 }
コード例 #4
0
 /// <summary>
 /// Create a new Department object.
 /// </summary>
 /// <param name="departmentID">Initial value of the DepartmentID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="budget">Initial value of the Budget property.</param>
 /// <param name="startDate">Initial value of the StartDate property.</param>
 public static Department CreateDepartment(global::System.Int32 departmentID, global::System.String name, global::System.Decimal budget, global::System.DateTime startDate)
 {
     Department department = new Department();
     department.DepartmentID = departmentID;
     department.Name = name;
     department.Budget = budget;
     department.StartDate = startDate;
     return department;
 }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Departments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDepartments(Department department)
 {
     base.AddObject("Departments", department);
 }
コード例 #6
0
 public void UpdateDepartment(Department department, Department origDepartment)
 {
     departments.Remove(origDepartment);
     departments.Add(department);
 }
コード例 #7
0
 public void InsertDepartment(Department department)
 {
     departments.Add(department);
 }
コード例 #8
0
 public void DeleteDepartment(Department department)
 {
     departments.Remove(department);
 }
コード例 #9
0
ファイル: SchoolBL.cs プロジェクト: JaySmith/Presentations
 public void InsertDepartment(Department department)
 {
     ValidateOneAdministratorAssignmentPerInstructor(department);
     try
     {
         schoolRepository.InsertDepartment(department);
     }
     catch (Exception ex)
     {
         //Include catch blocks for specific exceptions first,
         //and handle or log the error as appropriate in each.
         //Include a generic catch block like this one last.
         throw ex;
     }
 }
コード例 #10
0
ファイル: SchoolBL.cs プロジェクト: JaySmith/Presentations
 private void ValidateOneAdministratorAssignmentPerInstructor(Department department)
 {
     if (department.Administrator != null)
     {
         var duplicateDepartment = schoolRepository.GetDepartmentsByAdministrator(department.Administrator.GetValueOrDefault()).FirstOrDefault();
         if (duplicateDepartment != null && duplicateDepartment.DepartmentID != department.DepartmentID)
         {
             throw new DuplicateAdministratorException(String.Format(
                 "Instructor {0} {1} is already administrator of the {2} department.",
                 duplicateDepartment.Person.FirstMidName,
                 duplicateDepartment.Person.LastName,
                 duplicateDepartment.Name));
         }
     }
 }