public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,Status,AssigneeId,IssueId")] IssueTask issueTask)
        {
            if (id != issueTask.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(issueTask);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IssueTaskExists(issueTask.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToParentIssue(issueTask.IssueId));
            }
            ViewData["AssigneeId"] = issueTask.AssigneeId.HasValue ? new UserSelectList(_context.Users, issueTask.AssigneeId.Value) : new UserSelectList(_context.Users);
            ViewData["IssueId"]    = new IssueSelectList(_context.Issues, issueTask.IssueId);
            ViewData["StatusId"]   = new StatusSelectList(issueTask.Status);
            return(View(issueTask));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,Description,Status,AssigneeId,IssueId")] IssueTask issueTask)
        {
            if (ModelState.IsValid)
            {
                _context.Add(issueTask);
                await _context.SaveChangesAsync();

                return(RedirectToParentIssue(issueTask.IssueId));
            }
            ViewData["AssigneeId"] = issueTask.AssigneeId.HasValue ? new UserSelectList(_context.Users, issueTask.AssigneeId.Value) : new UserSelectList(_context.Users);
            ViewData["IssueId"]    = new IssueSelectList(_context.Issues, issueTask.IssueId);
            ViewData["StatusId"]   = new StatusSelectList(issueTask.Status);
            return(View(issueTask));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            IssueTaskVM = await _context.IssueTasks.FindAsync(id);

            if (IssueTaskVM != null)
            {
                _context.IssueTasks.Remove(IssueTaskVM);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            IssueTaskVM = await _context.IssueTasks
                          .Include(i => i.Assignee)
                          .Include(i => i.Issue).FirstOrDefaultAsync(m => m.Id == id);

            if (IssueTaskVM == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            IssueTaskVM = await _context.IssueTasks
                          .Include(i => i.Assignee)
                          .Include(i => i.Issue).FirstOrDefaultAsync(m => m.Id == id);

            if (IssueTaskVM == null)
            {
                return(NotFound());
            }
            ViewData["AssigneeId"] = new SelectList(_context.Users, "Id", "Id");
            ViewData["IssueId"]    = new SelectList(_context.Issues, "Id", "Id");
            return(Page());
        }