public ActionResult <PlatformReadDto> CreatePlatform(PlatformCreateDto platformCreate) { try { //Validations if (platformCreate == null) { return(NotFound()); } //Create var platform = _mapper.Map <Platform>(platformCreate); _repository.CreatePlatform(platform); _repository.SaveChanges(); //Read var platformRead = _repository.GetPlatformById(platform.Id); //Response return(CreatedAtRoute(nameof(GetPlatformById), new { Id = platformRead.Id }, platformRead)); } catch (Exception) { return(NotFound()); } }
private static void SeedData(ICommandRepo repo, IEnumerable <Platform> platforms) { Console.WriteLine("--> Seeding new platforms..."); foreach (var platform in platforms) { if (!repo.ExternalPlatformExists(platform.ExternalId)) { repo.CreatePlatform(platform); } } }