예제 #1
0
        public IHttpActionResult Create([FromBody] PCCreateModel pcGameToCreate)
        {
            _pcService = new PCGameService();
            _pcService.CreatePCGame(pcGameToCreate);

            return(Ok());
        }
예제 #2
0
 public void CreatePCGame(PCCreateModel pcGameToCreate)
 {
     using (ApplicationDbContext ctx = new ApplicationDbContext())
     {
         ctx.PCGames.Add(new PCGame(pcGameToCreate));
         ctx.SaveChanges();
     }
 }
예제 #3
0
 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;
 }
예제 #4
0
        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();
            }
        }