Пример #1
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Image")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Пример #2
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Description,CategoryId,Image")] Feed feed)
        {
            if (ModelState.IsValid)
            {
                db.Feeds.Add(feed);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", feed.CategoryId);
            return(View(feed));
        }