Example #1
0
        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());
            }
        }
Example #2
0
        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);
                }
            }
        }