public Publication ToPublication() { List<ObjectId> techiesId = new List<ObjectId>(); TechieBO techieBo = new TechieBO(); if (Techies.Count > 0) { Task.Run(async () => { foreach (var name in Techies) { var techie = await techieBo.SearchTechiePerName(name); if (techie != null) { techiesId.Add(techie.Id); } else { var newTechie = await techieBo.CreateTechie(new Techie { Name = name }); techiesId.Add(newTechie.Id); } } }).Wait(); } return new Publication { Title = Title, Description = Text, Techies = techiesId, UserId = UserId.ToObjectId() }; }
public async Task <IHttpActionResult> CreateTechie(CreateTechieViewModel model) { var result = await _techieBo.CreateTechie(model.ToTechie()); if (result != null) { return(Ok(result)); } return(InternalServerError()); }