示例#1
0
        public IHttpActionResult Create([FromBody] PlaystationGameCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _playstationService = new PlaystationService();

            _playstationService.CreatePlaystationGame(model);

            return(Ok());
        }
        public void CreatePlaystationGame(PlaystationGameCreateModel playstaionGameToCreate)
        {
            var entity = new PlaystationGame()
            {
                PlaystationGameId = playstaionGameToCreate.PlaystationGameId,
                Title             = playstaionGameToCreate.Title,
                Rating            = playstaionGameToCreate.Rating,
                MaturityRating    = playstaionGameToCreate.MaturityRating,
                Price             = playstaionGameToCreate.Price,
            };

            using (ApplicationDbContext context = new ApplicationDbContext())
            {
                context.PlaystationGames.Add(entity);
                context.SaveChanges();
            }
        }