public void AddDepartament(NewDepartament departament)
 { 
     if (departament != null)
     {
         Departament d = new Departament()
         {
             Name = departament.DepartamentName
         };
         SPDatabase.DB.Departaments.AddObject(d);
         SPDatabase.DB.SaveChanges();
     }
 }
 public bool AddDepartament(NewDepartament toAdd)
 {
     if (toAdd != null)
     {
         if (this.repository.DepartamentExists(toAdd.DepartamentName))
             toAdd.AddError("Wydział o podanej nazwie już istnieje");
         if (toAdd.IsValid)
         {
             this.repository.AddDepartament(toAdd);
             return true;
         }
     }
     return false;
 }
 private void btnAddDepartament_Click(object sender, EventArgs e)
 {
     lblValidation.Text = string.Empty;
     NewDepartament toAdd = new NewDepartament()
     {
         DepartamentName = txtNewDepartamentName.Text
     };
     if (!DepartamentController.Instance.AddDepartament(toAdd))
     {
         string errors = string.Empty;
         foreach (string error in toAdd.Errors)
             errors = errors + error + "\n";
         lblValidation.Text = errors;
     }
     else
     {
         FillWithDepartaments();
         Clear();
         changes = true;
     }
 }