public IHttpActionResult Create([FromBody] PCCreateModel pcGameToCreate) { _pcService = new PCGameService(); _pcService.CreatePCGame(pcGameToCreate); return(Ok()); }
public void CreatePCGame(PCCreateModel pcGameToCreate) { using (ApplicationDbContext ctx = new ApplicationDbContext()) { ctx.PCGames.Add(new PCGame(pcGameToCreate)); ctx.SaveChanges(); } }
public PCGame(PCCreateModel pcGameToCreate) { Title = pcGameToCreate.Title; Price = pcGameToCreate.Price; Genre = pcGameToCreate.Genre; MaturityRating = pcGameToCreate.MaturityRating; Rating = pcGameToCreate.Rating; Publisher = pcGameToCreate.Publisher; Developer = pcGameToCreate.Developer; }
public void CreatePCGame(PCCreateModel model) { var pcGameToCreate = new PCGame() { Title = model.Title, Price = model.Price, Genre = model.Genre, MaturityRating = model.MaturityRating, Rating = model.Rating, PublisherId = model.PublisherId, DeveloperId = model.DeveloperId }; using (ApplicationDbContext ctx = new ApplicationDbContext()) { ctx.PCGames.Add(pcGameToCreate); ctx.SaveChanges(); } }