/// <summary>Edits an existing movie.</summary> /// <param name="name">The movie to edit.</param> /// <param name="movie">The new movie.</param> public void Edit(string name, Movie movie) { if (name == null) { throw new ArgumentNullException(nameof(name)); } else if (name == "") { throw new ArgumentException("name cannot be empty", nameof(name)); } //Validate if (movie == null) { throw new ArgumentNullException(nameof(movie)); } ObjectValidator.Validate(movie); //Find movie by name var existing = FindByName(name); if (existing == null) { throw new Exception("movie no found."); } EditCore(existing, movie); }
public void Edit(string name, Movie movie) { ////TODO: Validate //if (String.IsNullOrEmpty(name)) // return; if (name == null) { throw new ArgumentNullException(nameof(name)); } else if (name == "") { throw new ArgumentNullException("Name cannot be empty.", nameof(name)); } //Validate if (movie == null) { throw new ArgumentNullException(nameof(movie)); } ObjectValidator.Validate(movie); //if (movie == null) // return; var existing = FindByName(name); if (existing == null) { throw new Exception("Movie not found."); //1 sentence message } EditCore(existing, movie); }
public void Add(Movie movie) { if (movie == null) { throw new ArgumentNullException(nameof(movie)); } ObjectValidator.Validate(movie); try { AddCore(movie); } catch (Exception e) { throw new Exception("Add Failed", e); }; }
public void Add(Movie movie) { //Validate if (movie == null) { throw new ArgumentNullException(nameof(movie)); } ObjectValidator.Validate(movie); //throw new Exception("Failed"); try { AddCore(movie); //implementation I.E. what you'res supposed to add or improve: Re-use functionality with } catch (Exception e) { throw new Exception("Add Failed", e); //chaining two exceptions together }; }
public void Add(Movie movie) { //Validate if (movie == null) { throw new ArgumentNullException("movie"); } ObjectValidator.Validate(movie); //if (movie == null) return; try { AddCore(movie); } catch (Exception e) { throw new Exception("Add failed", e); }; }