Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("TrailerID,Description,ProductGroup")] Trailer trailer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(trailer);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(trailer));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("FirstName,LastName,RegistrationDate,CreationDate")] Owner owner)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(owner);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("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(owner));
        }