Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Id,DateTimePreformed,ArenaId,SportId,PersonId,TimeSet1,TimeSet2,TimeSet3,TimeSet4,TimeTotal,Approved")] DustTest dustTest)
        {
            if (ModelState.IsValid)
            {
                var applicationContext = _context.DustTest
                                         .Include(d => d.Arena)
                                         .Include(d => d.Sport)
                                         .Include(d => d.TestedPerson);
                dustTest.TimeTotal = dustTest.TimeSet1 + dustTest.TimeSet2 + dustTest.TimeSet3 + dustTest.TimeSet4;


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

                return(RedirectToAction(nameof(IndexSearch)));
            }
            ViewData["ArenaId"]  = new SelectList(_context.Arena, "Id", "ArenaName", dustTest.ArenaId);
            ViewData["SportId"]  = new SelectList(_context.Set <Sport>(), "Id", "SportName", dustTest.SportId);
            ViewData["PersonId"] = new SelectList(_context.Set <Person>(), "Id", "FullName", dustTest.PersonId);
            return(View(dustTest));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DateTimePreformed,ArenaId,SportId,PersonId,TimeSet1,TimeSet2,TimeSet3,TimeSet4,TimeTotal,Approved")] DustTest dustTest)
        {
            if (id != dustTest.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var applicationContext = _context.DustTest
                                             .Include(d => d.Arena)
                                             .Include(d => d.Sport)
                                             .Include(d => d.TestedPerson);
                    dustTest.TimeTotal = dustTest.TimeSet1 + dustTest.TimeSet2 + dustTest.TimeSet3 + dustTest.TimeSet4;

                    _context.Update(dustTest);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DustTestExists(dustTest.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(IndexSearch)));
            }
            ViewData["ArenaId"]  = new SelectList(_context.Arena, "Id", "ArenaName", dustTest.ArenaId);
            ViewData["SportId"]  = new SelectList(_context.Set <Sport>(), "Id", "SportName", dustTest.SportId);
            ViewData["PersonId"] = new SelectList(_context.Set <Person>(), "Id", "FullName", dustTest.PersonId);
            return(View(dustTest));
        }