public async Task <bool> OnMultiStageFormCreate(Stagedform stagedform)
        {
            // Create a new Stage1, Stage2, and Stage3 form then update the StagedForm
            Stage1 newStage1 = new Stage1();

            newStage1.Name = "";
            _context.Stage1.Add(newStage1);

            Stage2 newStage2 = new Stage2();

            newStage2.Description = "";
            _context.Stage2.Add(newStage2);

            Stage3 newStage3 = new Stage3();

            newStage3.Date = DateTime.Now;
            _context.Stage3.Add(newStage3);

            await _context.SaveChangesAsync();

            stagedform.Stage1       = newStage1.Id;
            stagedform.Stage2       = newStage2.Id;
            stagedform.Stage3       = newStage3.Id;
            stagedform.CurrentStage = (int)MultiStageFormStages.First;
            _context.Update(stagedform);

            await _context.SaveChangesAsync();

            return(true);
        }
        public async Task <IActionResult> Create([Bind("Id,Name")] Stage1 stage1)
        {
            if (ModelState.IsValid)
            {
                _context.Add(stage1);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(stage1));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("Id,Stage1,Stage2,Stage3,CurrentStage")] Stagedform stagedform)
        {
            if (ModelState.IsValid)
            {
                MultiStageFormWorkflow multiStageFormWorkflow = new MultiStageFormWorkflow(_context);

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

                await multiStageFormWorkflow.OnMultiStageFormCreate(stagedform);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Stage1"] = new SelectList(_context.Stage1, "Id", "Name", stagedform.Stage1);
            ViewData["Stage2"] = new SelectList(_context.Stage2, "Id", "Description", stagedform.Stage2);
            ViewData["Stage3"] = new SelectList(_context.Stage3, "Id", "Id", stagedform.Stage3);
            return(View(stagedform));
        }