Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("id,FirstName,LastName,EmailAdress,ProductSerial")] Submission submission)
        {
            if (ModelState.IsValid)
            {
                IQueryable <Submission> Submissions = from s in _context.Submission
                                                      where s.ProductSerial == submission.ProductSerial
                                                      select s;
                IQueryable <PurchasedProduct> ValidSerials = from s in _context.PurchasedProduct
                                                             where s.ProductSerial == submission.ProductSerial
                                                             select s;

                if (Submissions.Count() < 2 && ValidSerials.Count() > 0)
                {
                    _context.Add(submission);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    return(RedirectToAction("ErrorPage", "Home", new { contentId = 3 }));
                }
            }
            return(View(submission));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Number,ReleaseDate")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

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