Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("UserId,UserName")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("CategoryId,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("LogItemId,LogItemDescription,LogItemPoints,CategoryId")] LogItem logItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(logItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "CategoryName", logItem.CategoryId);
            return(View(logItem));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("LogId,LogDate,UserId,LogItemId")] Log log)
        {
            if (ModelState.IsValid)
            {
                _context.Add(log);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LogItemId"] = new SelectList(_context.LogItems, "LogItemId", "LogItemDescription", log.LogItemId);
            ViewData["UserId"]    = new SelectList(_context.Users, "UserId", "UserName", log.UserId);
            return(View(log));
        }