Example #1
0
 public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] SubjectBlockType subjectBlockType)
 {
     if (id != subjectBlockType.Id)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(subjectBlockType);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!SubjectBlockTypeExists(subjectBlockType.Id))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(subjectBlockType));
 }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,Name")] SubjectBlockType subjectBlockType)
        {
            var subjectBlocks = _context.SubjectBlockTypes.ToList();

            ViewBag.subjectBlock = subjectBlocks;
            if (ModelState.IsValid)
            {
                _context.Add(subjectBlockType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Create)));
            }
            return(View(subjectBlockType));
        }