public Ticket UpdateTicket(long id, eTicketState newState, eTicketType newType, string assignedTo) { var ticket = GetTicket(id); if (ticket == null) { return(null); } if (newState != eTicketState.Undefined && ticket.State != newState) { ticket.State = newState; if (newState == eTicketState.Done || newState == eTicketState.Denied) { ticket.ClosedTs = DateTime.Now; } } if (newType != eTicketType.Undefined) { ticket.Type = newType; } if (!string.IsNullOrEmpty(ticket.AssignedTo)) { ticket.AssignedTo = assignedTo; } _dbContext.SaveChanges(); return(ticket); }
public IEnumerable <TicketSmall> GetTicketsSmall(string projectName, eTicketType type, eTicketState state) { Project project = null; if (!string.IsNullOrWhiteSpace(projectName)) { project = _dbContext.Projects.FirstOrDefault(ll => ll.Name == projectName); if (project == null) { return(new List <TicketSmall>()); } } return(GetTicketsSmall(project?.Id, type, state)); }
public IEnumerable <TicketSmall> GetTicketsSmall(long?project, eTicketType type, eTicketState state) { IQueryable <TicketSmall> retVal = _dbContext.TicketsSmall; if (project != null) { Project proj = _dbContext.Projects.SingleOrDefault(ll => ll.Id == project); if (proj != null) { retVal = retVal.Where(ll => ll.Project == proj.Name); } } if (type != eTicketType.Undefined) { retVal = retVal.Where(ll => ll.Type == type); } if (state != eTicketState.Undefined) { retVal = retVal.Where(ll => ll.State == state); } return(retVal.ToList()); }
public IEnumerable <TicketSmall> Get([FromQuery] long?project, eTicketType type, eTicketState state) { _logger.LogInformation($"GetTicketsSmall: project: {project} type: {type}, state: {state}"); return(_ticketService.GetTicketsSmall(project, type, state)); }
public async Task <IActionResult> TicketAdd(long projectId, eTicketType type = eTicketType.Feature, eTicketState state = eTicketState.New) { TicketAddViewModel model = new TicketAddViewModel(); model.Projects = _ticketService.GetProjects().ToList(); model.SelectedProject = model.Projects.FirstOrDefault(ll => ll.Id == projectId); model.Type = type; model.State = state; if (model.SelectedProject != null) { model.AssignableUsers = (await _projectRolesService.GetUsersWithProjectRoleForProject(model.SelectedProject.Name)).projectUser.Where(ll => ll.Role > eProjectRoles.Reporter).ToList(); } else { model.AssignableUsers = new List <ProjectUserWithRole>(); } return(View(model)); }
public async Task <IActionResult> MarkAllTicketsSeen(bool seen, long projectId, eTicketType type, eTicketState state) { var tickets = _ticketService.GetTicketsSmall(projectId, type, state).ToList(); foreach (var ticket in tickets) { if (seen) { await _ticketService.MarkTicketAsSeen(ticket.Id, User.Identity.Name); } else { await _ticketService.MarkTicketAsUnSeen(ticket.Id, User.Identity.Name); } } return(RedirectToAction("Tickets", new { seen, projectId, type, state })); }
public async Task <IActionResult> Tickets(long projectId, eTicketType type = eTicketType.Undefined, eTicketState state = eTicketState.Undefined) { TicketsViewModel model = new TicketsViewModel(); model.Projects = _ticketService.GetProjects().ToList(); model.SelectedProject = model.Projects.FirstOrDefault(ll => ll.Id == projectId); model.Tickets = _ticketService.GetTicketsSmall(projectId, type, state).ToList(); model.TicketType = type; model.TicketState = state; if (User.Identity.IsAuthenticated) { await _ticketService.SetUserSeenTicketFlag(model.Tickets, User.Identity.Name); } return(View(model)); }