public ActorDTO(Actor source) { ID = source.ID; Name = source.Name; DateOfBirth = source.DateOfBirth; StarredIn = source.StarredIn.Select(x => x.ID).ToArray(); }
/// <summary> /// Adds a new actor to the database. /// </summary> /// <param name="value"></param> public void Post([FromBody]ActorDTO value) { Actor dbActor = new Actor(); dbActor.Name = value.Name; dbActor.DateOfBirth = value.DateOfBirth; dbActor.StarredIn = _db.Movies.Where(x => value.StarredIn.Contains(x.ID)).ToList(); _db.Actors.Add(dbActor); _db.SaveChanges(); }
private ActorDTO ConvertToDTO(Actor actor) { return new ActorDTO(actor); }