Beispiel #1
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Workflow,Context")] HookViewModel hookViewModel)
        {
            if (id != hookViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var hook = hookViewModel.ToEntity();
                try
                {
                    _context.Update(hook);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HookExists(hook.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.isEdit = true;
            ViewBag.types  = Constants.allowedTypes;
            return(View("CreateEdit", hookViewModel));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,Workflow,Context")] HookViewModel hookViewModel)
        {
            if (ModelState.IsValid)
            {
                var hook = hookViewModel.ToEntity();
                _context.Add(hook);
                await _context.SaveChangesAsync();

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

            ViewBag.types = Constants.allowedTypes;
            return(View("CreateEdit", hookViewModel));
        }