示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("TaskID,ProjectID,TaskName,TaskDescription,TaskStartDate,TaskDeadline,Completed")] Tasks tasks)
        {
            if (id != tasks.TaskID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tasks);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TasksExists(tasks.TaskID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "Projects", new { id = tasks.ProjectID }));
            }
            return(View(tasks));
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, [Bind("ProjectID,UserID,ProjectName,ProjectDescription,ProjectDate")] Projects projects)
        {
            if (id != projects.ProjectID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    projects.UserID = _userManager.GetUserId(User);
                    _context.Update(projects);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectsExists(projects.ProjectID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(projects));
        }