예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,_Cost,_Name,Type,Color,Firm,Description,ImageUrl,Size")] Stuff stuff)
        {
            if (ModelState.IsValid)
            {
                db.Add(stuff);
                await db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(stuff));
        }
예제 #2
0
        public async Task <IActionResult> Create(int id, int rate, string _text)
        {
            User   currentUser = _context.Users.FirstOrDefault(x => x._Username == User.Identity.Name);
            Review review      = new Review {
                UserId = currentUser.Id, StuffId = id, Rate = rate, _Text = _text
            };

            _context.Add(review);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", "Store"));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,_Text,UserId,ArticleId")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArticleId"] = new SelectList(_context.Articles, "Id", "Id", comment.ArticleId);
            ViewData["UserId"]    = new SelectList(_context.Users, "Id", "Id", comment.UserId);
            return(View(comment));
        }