Example #1
0
        public async Task <IActionResult> PutCooperTest([FromRoute] int id, [FromBody] CooperTest cooperTest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cooperTest.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cooperTest).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CooperTestExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> PostCooperTest([FromBody] CooperTest cooperTest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.CooperTests.Add(cooperTest);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCooperTest", new { id = cooperTest.Id }, cooperTest));
        }
Example #3
0
        public async Task <IActionResult> AddorEdit([Bind("TestID,TestName")] CooperTest cooperTest)
        {
            if (ModelState.IsValid)
            {
                if (cooperTest.TestID == 0)
                {
                    _context.Add(cooperTest);
                }
                else
                {
                    _context.Update(cooperTest);
                }
                await _context.SaveChangesAsync();

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