public IHttpActionResult Create([FromBody] SwitchCreateModel switchToCreate) { _switchService = new SwitchService(); _switchService.CreateSwitchGame(switchToCreate); return(Ok()); }
public IHttpActionResult Create([FromBody] SwitchCreateModel switchToCreate) { _switchService = new SwitchService(); _switchService.CreateSwitchGame(switchToCreate); return(Ok($"{switchToCreate.Name} has been successfully created!")); }
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(); } }