示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id, Author, ProjectName, userId, projectLanguage")] Projects Project)
        {
            ClaimsPrincipal currentUser   = this.User;
            var             currentUserID = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;

            ViewBag.userId = currentUserID;


            if (id != Project.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(Project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
                return(RedirectToAction("Index"));
            }
            return(View(Project));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Message,CreatedDateTime")] Comment comment)
        {
            if (id != comment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(comment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CommentExists(comment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(comment));
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description")] Project project)
        {
            if (id != project.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,Priority,Status,Type,CreationDate")] Ticket ticket)
        {
            if (id != ticket.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ticket);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TicketExists(ticket.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(ticket));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
示例#6
0
        public async Task <IActionResult> Edit(int id, TicketsCreateOrEditVM rvm)
        {
            if (id != rvm.ticket.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                Ticket t = new Ticket
                {
                    Id          = rvm.ticket.Id,
                    ProjectId   = rvm.ticket.ProjectId,
                    Title       = rvm.ticket.Title,
                    Description = rvm.ticket.Description,
                    SubmitterId = _userManager.GetUserId(User),
                    DateCreated = rvm.ticket.DateCreated,
                    DeveloperId = rvm.ticket.DeveloperId,
                    Priority    = rvm.ticket.Priority,
                    Severity    = rvm.ticket.Severity,
                    Status      = rvm.ticket.Status
                };

                try
                {
                    _context.Update(t);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TicketExists(rvm.ticket.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            var projectsQuery = from d in _context.Projects
                                orderby d.Title
                                select d;
            var allDevelopers = await _userManager.GetUsersInRoleAsync("Developer");

            var vm = new TicketsCreateOrEditVM
            {
                Projects   = new SelectList(projectsQuery, "Id", "Title"),
                Developers = new SelectList(allDevelopers, "Id", "Email"),
                ticket     = rvm.ticket
            };

            return(View(vm));
        }
示例#7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,OwnerId,Title,Description,DateCreated")] Project project)
        {
            if (id != project.Id)
            {
                return(NotFound());
            }

            var uneditedProject = await _context.Projects
                                  .AsNoTracking()
                                  .FirstOrDefaultAsync(m => m.Id == id);

            if (uneditedProject.OwnerId != project.OwnerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var isAuthorized = await _authorizationService.AuthorizeAsync(User, project, ProjectOperations.Update);

                if (!isAuthorized.Succeeded)
                {
                    return(Forbid());
                }

                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProjectExists(project.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(project));
        }
示例#8
0
        public async Task <IActionResult> Edit(int id, [Bind("TicketId, TicketName, TicketDesc, userId, ProjectId, TicketPriority")] Tickets Ticket)
        {
            if (id != Ticket.TicketId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(Ticket);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
                return(RedirectToAction("Index"));
            }
            return(View(Ticket));
        }