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> PutSeverity(Guid id, Severity severity) { if (id != severity.Id) { return(BadRequest()); } _context.Entry(severity).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SeverityExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Message,CreatedDateTime")] Comment comment) { if (ModelState.IsValid) { _context.Add(comment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(comment)); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,Priority,Status,Type,CreationDate")] Ticket ticket) { if (ModelState.IsValid) { _context.Add(ticket); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(ticket)); }
public async Task <IActionResult> Create([Bind("Id,Title,Description")] Project project) { if (ModelState.IsValid) { _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(project)); }
public async Task <IActionResult> Create([Bind("Id,Name,Email")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <ActionResult <Project> > CreateProject([FromBody] ProjectPostRequest project) { var newProject = new Project { Name = project.Name, Description = project.Description, Created = DateTime.UtcNow }; _context.Projects.Add(newProject); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetProject), new { id = newProject.Id }, newProject)); }
public async Task <ProjectItem> CreateProject(CreateProjectItemCommand command) { var projectItem = new ProjectItem { Created = DateTime.UtcNow, Description = command.Description, Modified = DateTime.UtcNow, Name = command.Name, }; _context.ProjectItems.Add(projectItem); await _context.SaveChangesAsync(); return(projectItem); }
public async Task <TaskItem> CreateTask(CreateTaskItemCommand command) { var taskItem = new TaskItem { Created = DateTime.UtcNow, Modified = DateTime.UtcNow, ProjectID = command.ProjectID, Description = command.Description, Name = command.Name, Priority = command.Priority, Status = TaskItem.TaskStatus.New }; _context.TaskItems.Add(taskItem); await _context.SaveChangesAsync(); return(taskItem); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,DateCreated")] Project project) { if (ModelState.IsValid) { project.OwnerId = _userManager.GetUserId(User); //var isAuthorized = await _authorizationService.AuthorizeAsync(User, project, ProjectOperations.Create); //if (!isAuthorized.Succeeded) //{ // return Forbid(); //} _context.Add(project); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(project)); }
public async Task <IActionResult> Create(TicketsCreateOrEditVM rvm) { if (ModelState.IsValid) { // rvm.ticket.SubmitterId = _userManager.GetUserId(User); 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 }; _context.Add(t); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //PopulateProjectsDropDownList(); //select all projects, order by title 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") }; return(View(vm)); }
public async Task <IActionResult> Create([Bind("Id,Name,Email,Role")] User user) { try { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(user)); }
public async Task <IActionResult> Create(int?id, [Bind("TicketId, TicketName, TicketDesc, userId, ProjectId, TicketPriority")] Tickets Ticket) { // 0:dd/MMM/yyyy HH:mm:ss // Get Current DateTime ViewBag.creationDate = DateTime.Now; //.ToString("0:dd/MMM/yyyy HH:mm:ss"); ViewBag.userId = Ticket.userId; ViewBag.projectId = Ticket.ProjectId; Ticket.CreationDate = DateTime.Now; //DateTime.Now.ToString("0:dd/MMM/yyyy HH:mm:ss"); // Add the ticket to the project's TicketList if (Ticket.ProjectId == 0) { return(NotFound()); } var project = await _context.Projects.FirstOrDefaultAsync(m => m.Id == Ticket.ProjectId); if (project != null) { project.TicketList.Add(Ticket); } if (project == null) { return(NotFound()); } if (ModelState.IsValid) { _context.Add(Ticket); await _context.SaveChangesAsync(); return(RedirectToAction("Project", new { id = Ticket.ProjectId })); } return(View(Ticket)); }
public async Task <IActionResult> Index(AllProjectsViewModel allProjectsVM) { if (ModelState.IsValid) { var user = await userManager.GetUserAsync(User); var project = new Project { Title = allProjectsVM.Title, ManagerId = user.Id }; await context.Projects.AddAsync(project); await context.SaveChangesAsync(); var projectUser = new ProjectUser(); projectUser.Project = project; projectUser.User = user; await context.projectUsers.AddAsync(projectUser); await context.SaveChangesAsync(); } return(RedirectToAction("Index")); }