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,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,Name,Email")] User user) { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(user)); }
public void Initialize(BugTrackerContext context) { if (!context.ProjectItems.Any()) { context.Add(new ProjectItem { Name = "Task 1", Description = "Task 1", Created = DateTime.UtcNow.AddDays(1), Modified = DateTime.UtcNow.AddDays(1) }); context.Add(new ProjectItem { Name = "Task 2", Description = "Task 2", Created = DateTime.UtcNow.AddDays(-1), Modified = DateTime.UtcNow.AddDays(-1) }); context.Add(new ProjectItem { Name = "Task 3", Description = "Task 3", Created = DateTime.UtcNow.AddDays(2), Modified = DateTime.UtcNow.AddDays(2) }); } if (!context.TaskItems.Any()) { context.Add(new TaskItem { Name = "Task 1", Description = "Task 1", Priority = TaskItem.TaskPriority.High, Created = DateTime.Now.AddDays(1), Modified = DateTime.UtcNow.AddDays(1) }); context.Add(new TaskItem { Name = "Task 2", Description = "Task 2", Priority = TaskItem.TaskPriority.Low, Created = DateTime.Now.AddDays(-1), Modified = DateTime.UtcNow.AddDays(-1) }); context.Add(new TaskItem { Name = "Task 3", Description = "Task 3", Priority = TaskItem.TaskPriority.Medium, Created = DateTime.Now.AddDays(2), Modified = DateTime.UtcNow.AddDays(2) }); } context.SaveChanges(); }
public async Task <IActionResult> Create([Bind("Id, Author, ProjectName, userId, projectLanguage")] Projects Project) { ClaimsPrincipal currentUser = this.User; var currentUserID = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value; ViewBag.userId = currentUserID; if (ModelState.IsValid) { _context.Add(Project); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(Project)); }
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)); }