public IHttpActionResult Create([FromBody] XboxCreateModel xboxToCreate) { _xboxService = new XboxService(); _xboxService.CreateXboxGame(xboxToCreate); return(Ok($"{xboxToCreate.Name} has been successfully created!")); }
public IHttpActionResult Create([FromBody] XboxCreateModel xboxToCreate) { _xboxService = new XboxService(); _xboxService.CreateXboxGame(xboxToCreate); return(Ok()); }
public void CreateXboxGame(XboxCreateModel model) { var xboxToCreate = new XboxGame() { 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.XboxGames.Add(xboxToCreate); ctx.SaveChanges(); } }