예제 #1
0
        public IHttpActionResult Create([FromBody] SwitchCreateModel switchToCreate)
        {
            _switchService = new SwitchService();

            _switchService.CreateSwitchGame(switchToCreate);

            return(Ok());
        }
예제 #2
0
        public IHttpActionResult Create([FromBody] SwitchCreateModel switchToCreate)
        {
            _switchService = new SwitchService();

            _switchService.CreateSwitchGame(switchToCreate);

            return(Ok($"{switchToCreate.Name} has been successfully created!"));
        }
예제 #3
0
        public void CreateSwitchGame(SwitchCreateModel model)
        {
            var switchToCreate = new SwitchGame()
            {
                Name           = model.Name,
                Price          = model.Price,
                Genre          = model.Genre,
                MaturityRating = model.MaturityRating,
                Rating         = model.Rating,
                DeveloperId    = model.DeveloperId,
                PublisherId    = model.PublisherId
            };

            using (ApplicationDbContext ctx = new ApplicationDbContext())
            {
                ctx.SwitchGames.Add(switchToCreate);
                ctx.SaveChanges();
            }
        }