public Actor Create() { Console.WriteLine(interfaceGenerator.CreateGeneralInstructions()); var actor = new Actor(); Console.WriteLine(interfaceGenerator.FName()); actor.FirstName = reader.Read(); Console.WriteLine(interfaceGenerator.LName()); actor.LastName = reader.Read(); Console.WriteLine(interfaceGenerator.YBorn()); actor.YearBorn = int.Parse(reader.Read()); Console.WriteLine(interfaceGenerator.SBio()); actor.ShortBio = reader.Read(); return(actor); }
public void Execute() { this.writer.Write(this.interfaceGenerator.CreateGeneralInstructions()); var actor = new Actor(); this.writer.Write(interfaceGenerator.FName()); actor.FirstName = this.reader.Read(); this.writer.Write(interfaceGenerator.LName()); actor.LastName = this.reader.Read(); this.writer.Write(interfaceGenerator.YBorn()); actor.YearBorn = int.Parse(reader.Read()); this.writer.Write(interfaceGenerator.SBio()); actor.ShortBio = this.reader.Read(); this.writer.Write(interfaceGenerator.ToWhichFilm()); var filmTitle = this.reader.Read(); Film currentFilm; try { currentFilm = this.context.Films.Where(f => f.Title == filmTitle).First(); } catch (Exception) { throw new Exception("Film with this title can't found in the database"); } currentFilm.Actors.Add(actor); this.context.SaveChanges(); this.writer.Write($"Actor {actor.FirstName} {actor.LastName} is added to movie {filmTitle}."); }