Beispiel #1
0
        public IActionResult Index(int id)
        {
            Category category = new Category();

            using (BuyItContext buyItContext = new BuyItContext())
            {
                category = buyItContext.Categories.SingleOrDefault(x => x.Id == id);
            }

            ViewData["Title"] = category.Name;
            return(View(category));
        }
Beispiel #2
0
        public IActionResult Handle()
        {
            string json = HttpContext.Request.Form["JSON"].ToString();

            DTO.ProductSaveDto productSave = Newtonsoft.Json.JsonConvert.DeserializeObject <DTO.ProductSaveDto>(json);

            using (BuyItContext buyItContext = new BuyItContext())
            {
                buyItContext.Products.Add(new Models.Product()
                {
                    Name        = productSave.productName,
                    Description = "boş",
                    CreateDate  = DateTime.UtcNow,
                    StateId     = (int)Enums.State.Active,
                    CategoryId  = productSave.categoryId
                });

                buyItContext.SaveChanges();
            }

            return(View());
        }