Ejemplo n.º 1
0
 public async Task<IActionResult> Create([Bind("IssueId,Topic,Description,CreateDate,CloseDate")] Issue issue)
 {
     if (ModelState.IsValid)
     {
         _context.Add(issue);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(issue);
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,Description,Category,TicketDate")] Ticket ticket)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ticket);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ticket));
        }
        public async Task <IActionResult> Create([Bind("LastName,FirstMidName")] User user)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(user);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }

            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }

            return(View(user));
        }