public bool AddStudiesType(NewStudiesType toAdd) { StudiesType s = this.repository.GetStudiesType(toAdd.StudiesTypeName); if (s != null) toAdd.AddError("Typ studiów o takiej nazwie już\nistnieje"); if (toAdd.IsValid) { this.repository.AddStudiesType(toAdd); return true; } return false; }
public void AddStudiesType(NewStudiesType toAdd) { if (toAdd != null) { StudiesType st = new StudiesType() { Name = toAdd.StudiesTypeName, }; SPDatabase.DB.StudiesTypes.AddObject(st); SPDatabase.DB.SaveChanges(); } }
private void btnAdd_Click(object sender, EventArgs e) { lblValidation.Text = string.Empty; NewStudiesType toAdd = new NewStudiesType() { StudiesTypeName = tbNewStudiesTypeName.Text }; if (!StudiesTypeController.Instance.AddStudiesType(toAdd)) { string errors = string.Empty; foreach (string error in toAdd.Errors) errors = errors + error + "\n"; lblValidation.Text = errors; } else { FillWithStudiesTypes(); Clear(); changes = true; } }