예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("PersonId,Name,Surname")] Person person)
        {
            if (id != person.PersonId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(person);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonExists(person.PersonId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("BugId,Created,Title,Description,IsClosed")] Bug bug)
        {
            if (id != bug.BugId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bug);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BugExists(bug.BugId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bug));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ProjectID,ProjectName,ManagerID")] Project project)
        {
            if (id != project.ProjectID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.ProjectID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            List <BugTrackerUser> Managers = new List <BugTrackerUser>();

            foreach (BugTrackerUser user in _context.BugTrackerUsers)
            {
                if (rolesManipulator.GetUserRoles(user.BugTrackerUserID).ID == RolesIDs.ManagerID)
                {
                    Managers.Add(user);
                }
            }

            ViewData["ManagerID"] = new SelectList(Managers, "BugTrackerUserID", "Name");
            return(View(project));
        }
예제 #4
0
        public async Task <IActionResult> Edit(string id, [Bind("BugTrackerUserID,Name,Age")] BugTrackerUser bugTrackerUser, string role)
        {
            if (id != bugTrackerUser.BugTrackerUserID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Role currentUserRole = rolesManipulator.GetUserRoles(bugTrackerUser.BugTrackerUserID);

                    if (currentUserRole.ID != role)
                    {
                        rolesManipulator.DeleteRoleFromUser(bugTrackerUser.BugTrackerUserID, currentUserRole.ID);
                        rolesManipulator.AssignRoleToUser(bugTrackerUser.BugTrackerUserID, role);
                    }

                    _context.Update(bugTrackerUser);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BugTrackerUserExists(bugTrackerUser.BugTrackerUserID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(bugTrackerUser));
        }
예제 #5
0
 public void UpdateTicket(Ticket ticket)
 {
     db.Update(ticket);
     db.SaveChanges();
 }