private bool ValidateAlbum(Album album) { if (string.IsNullOrEmpty(album.Name)) { _validationDictionary.AddError("Name", "Name field is not filled"); } return _validationDictionary.IsValid; }
public void InsertOrUpdate(Album album) { if (album.ID == default(int)) { // New entity context.Albums.Add(album); } else { // Existing entity context.Entry(album).State = EntityState.Modified; } }
public bool CreateAlbum(Album newAlbum) { // Validation logic if (!ValidateAlbum(newAlbum)) return false; try { _repository.InsertOrUpdate(newAlbum); _repository.Save(); } catch { return false; } return true; }