
import {MdSnackBar} from '@angular/material';

export abstract class CommonCrudService {

  constructor(private snackBar: MdSnackBar) {
  }

  // todo refactor crud operations to here (use metadata?)
  onOperationPerformedNotify(opName: string): (res: boolean) => void {
    return (res) => {
      let text;
      if (res) {
        text = `Successful ${opName}!`;
      } else {
        text = `Failed to ${opName}!`;
      }
      this.snackBar.open(text, null, {
        duration: 1000
      });
    };
  }
}
