public ActionResult List(string Username, string RepositoryName, string State) { IssueState state = State == "open" ? IssueState.Open : IssueState.Closed; IEnumerable <Issue> issues = BaseAPI.List(RepositoryName, Username, state); return(View("List", GetBaseView(issues))); }
public async Task<ServiceResult> ChangeState(int issueId, IssueState newState) { var result = new ServiceResult(); try { //franc se tudja miért, de ha nincs ráincludeolva a project, elszáll a required miatt... var issue = await context.Issues.Include(i => i.Project).SingleOrDefaultAsync(i => i.Id == issueId); if (issue == null) { result.AddError("", "Nincs ilyen azonosítójú feladat."); return result; } issue.State = newState; await context.SaveChangesAsync(); } catch (Exception e) { result.AddError("", e.Message); } return result; }
private IList <IssueState> UpdateOrder(IssueStateModel updatedModel, IssueState stateToUpdate, BoardContext context) { var allStatesForBoard = context.IssueStates.Where(x => x.BoardId == stateToUpdate.BoardId).ToList(); var otherStates = allStatesForBoard.Where(x => x.Id != stateToUpdate.Id) .OrderBy(x => x.Order) .ToList(); var oldOrder = stateToUpdate.Order; var newOrder = updatedModel.Order; if (newOrder < 0) { newOrder = 0; } if (newOrder >= allStatesForBoard.Count) { newOrder = allStatesForBoard.Count - 1; } for (int i = 0; i < otherStates.Count; i++) { otherStates[i].Order = i; } foreach (var state in otherStates.Where(x => x.Order >= newOrder)) { state.Order += 1; } stateToUpdate.Order = newOrder; return(allStatesForBoard); }
private async Task <Response> AddNote(int requestId, string noteArea, IssueState state) { this.RequiresClaims(UserClaims.Admin); var issue = await IssuesService.GetAsync(requestId); if (issue == null) { return(Response.AsJson(new JsonResponseModel { Result = false, Message = "Issue does not exist to add a note!" })); } var toAddNote = issue.Issues.FirstOrDefault(x => x.Issue == state); if (toAddNote != null) { issue.Issues.Remove(toAddNote); toAddNote.AdminNote = noteArea; issue.Issues.Add(toAddNote); } var result = await IssuesService.UpdateIssueAsync(issue); return(Response.AsJson(result ? new JsonResponseModel { Result = true } : new JsonResponseModel { Result = false, Message = "Could not update the notes, please try again or check the logs" })); }
public Issue(string name, string description, int author, int assignee, IssueState state) { Name = name; Description = description; Author = author; Assignee = assignee; State = state; }
public IssueResponse[] List(string repository, string owner, IssueState issueState) { var state = issueState == IssueState.Open ? "open" : "closed"; var url = GetPathByDefault(repository, owner, "?state={0}", state); AppendPerPageLimit(ref url); return(ConsumeJsonUrl <IssueResponse[]>(url)); }
public MyIssuesFilterModel(IssueFilterState filterState = IssueFilterState.All, IssueState issueState = IssueState.Open, IssueSort sort = IssueSort.None, string labels = null, bool ascending = false) { SortType = sort; Open = issueState; Ascending = ascending; FilterType = filterState; Labels = labels; }
private string GetParameter(IssueState state, string labels) { var builder = new StringBuilder("?"); builder.Append("state=" + state.ToString().ToLower()); builder.Append(labels != null ? "&labels=" + labels : ""); return(builder.ToString()); }
public MyIssuesFilterViewModel Init(MyIssuesFilterModel model) { Ascending = model.Ascending; FilterType = model.FilterType; Labels = model.Labels; State = model.Open; SortType = model.SortType; return(this); }
public async Task GetOwned_StateIsSet_AddsStateParameter() { const string expected = "opened"; const IssueState state = IssueState.Opened; await _sut.GetOwned(state); _request.Received().AddParameterIfNotNull("state", expected); }
void WhenItIsRetrieved(Uri uri) { Request.RequestUri = uri; Response = Client.SendAsync(Request).Result; if (Response.Content != null) { _issueState = Response.Content.ReadAsAsync <IssueState>().Result; } }
public async Task GetByProject_StateIsSet_AddsStateParameter() { const string expected = "closed"; const IssueState state = IssueState.Closed; await _sut.GetByProject(0, state); _request.Received().AddParameterIfNotNull("state", expected); }
public virtual void ChangeState(User user, IssueState state) { if (State != state) { ChangeStates.Add(new ChangeState() { CreatedAt = DateTime.Now, IssueState = state, User = user, Issue = this }); } }
public static IssueStateModel ToModel(this IssueState issueState) { return(new IssueStateModel() { Id = issueState.Id, Name = issueState.Name, BoardId = issueState.BoardId, Order = issueState.Order }); }
public async Task <List <Issue> > DownloadIssueList(IssueState state, string labels) { using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "DSM-SCIMS-App"); var jsonString = await client.GetStringAsync("https://api.github.com/repos/DSM-HS/StudentCouncil/issues" + GetParameter(state, labels)); return(JsonConvert.DeserializeObject <List <Issue> >(jsonString)); } }
public IssueSearchResult[] Search(string repository, string owner, IssueState issueState, string search) { var state = issueState == IssueState.Open ? "open" : "closed"; var url = string.Format("legacy/issues/search/{0}/{1}/{2}/{3}", owner, repository, state, search); var result = ConsumeJsonUrl<IssueSearchResponse>(url); return result != null ? result.Issues : new IssueSearchResult[] { }; }
private async Task <Negotiator> ClearIssue(int issueId, IssueState state) { this.RequiresClaims(UserClaims.Admin); var issue = await IssuesService.GetAsync(issueId); var toRemove = issue.Issues.FirstOrDefault(x => x.Issue == state); issue.Issues.Remove(toRemove); var result = await IssuesService.UpdateIssueAsync(issue); return(result ? await Details(issueId) : View["Index"]); }
private TaskboardColumn GetTaskboardColumn(IssueState issueState) { var columns = GetColumns(); foreach (var column in columns) { if (column.IsInThisColumn(issueState)) { return(column); } } return(null); }
public IssuesFilterModel(User assignee = null, string creator = null, string mentioned = null, IReadOnlyList<Label> labels = null, Milestone milestone = null, IssueState issueState = IssueState.Open, IssueSort sortType = IssueSort.None, bool ascending = false) { Assignee = assignee; Creator = creator; Mentioned = mentioned; Labels = labels; this.Milestone = milestone; this.IssueState = issueState; SortType = sortType; Ascending = ascending; }
public IssuesFilterModel(User assignee = null, string creator = null, string mentioned = null, IReadOnlyList <Label> labels = null, Milestone milestone = null, IssueState issueState = IssueState.Open, IssueSort sortType = IssueSort.None, bool ascending = false) { Assignee = assignee; Creator = creator; Mentioned = mentioned; Labels = labels; this.Milestone = milestone; this.IssueState = issueState; SortType = sortType; Ascending = ascending; }
public RepositoryIssuesFilterViewModel Init(string repositoryOwner, string repositoryName, IssuesFilterModel model) { RepositoryOwner = repositoryOwner; RepositoryName = repositoryName; Assignee = model.Assignee; Creator = model.Creator; Milestone = model.Milestone; Labels = model.Labels; Mentioned = model.Mentioned; SortType = model.SortType; State = model.IssueState; Ascending = model.Ascending; return(this); }
public IssueSearchResult[] Search(string repository, string owner, IssueState issueState, string search) { var state = issueState == IssueState.Open ? "open" : "closed"; var url = string.Format("legacy/issues/search/{0}/{1}/{2}/{3}", owner, repository, state, search); AppendPerPageLimit(ref url); var result = ConsumeJsonUrl <IssueSearchResponse>(url); return(result != null ? result.Issues : new IssueSearchResult[] { }); }
public IActionResult Post(int boardId, string name) { var state = new IssueState { Name = name, BoardId = boardId }; _context.IssueStates.Add(state); _context.SaveChanges(); _connectionManager.BroadcastAddState(Result.ToModel(state)); return(Result.Created(state)); }
public ActionResult Edit([Bind(Include = "Id,Title,Description,StateId")] IssueViewModel issue, int pid) { IncludeProject(pid); if (ModelState.IsValid) { IssueState state = db.IssueStates.Where(p => p.Id == issue.StateId).FirstOrDefault(); Issue iss = db.Issues.Where(p => p.Id == issue.Id).Include(p => p.Project).Include(p => p.CreatedBy).Include(p => p.State).Include(p => p.Comments).FirstOrDefault(); iss.Title = issue.Title; iss.Description = issue.Description; iss.State = state; db.Entry(iss).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(issue)); }
public MyIssuesFilterViewModel(IActionMenuFactory actionMenu) { Title = "Filter"; State = IssueState.Open; SortType = IssueSort.None; FilterType = IssueFilterState.All; SaveCommand = ReactiveCommand.CreateAsyncTask(_ => Task.FromResult(new MyIssuesFilterModel(FilterType, State, SortType, Labels, Ascending))); SaveCommand.Subscribe(_ => DismissCommand.ExecuteIfCan()); DismissCommand = ReactiveCommand.Create().WithSubscription(_ => Dismiss()); SelectStateCommand = ReactiveCommand.CreateAsyncTask(async sender => { var options = Enum.GetValues(typeof(IssueState)).Cast <IssueState>().ToList(); var picker = actionMenu.CreatePicker(); foreach (var option in options) { picker.Options.Add(option.Humanize()); } picker.SelectedOption = options.IndexOf(State); var ret = await picker.Show(sender); State = options[ret]; }); SelectSortCommand = ReactiveCommand.CreateAsyncTask(async sender => { var options = Enum.GetValues(typeof(IssueSort)).Cast <IssueSort>().ToList(); var picker = actionMenu.CreatePicker(); foreach (var option in options) { picker.Options.Add(option.Humanize()); } picker.SelectedOption = options.IndexOf(SortType); var ret = await picker.Show(sender); SortType = options[ret]; }); SelectFilterTypeCommand = ReactiveCommand.CreateAsyncTask(async sender => { var options = Enum.GetValues(typeof(IssueFilterState)).Cast <IssueFilterState>().ToList(); var picker = actionMenu.CreatePicker(); foreach (var option in options) { picker.Options.Add(option.Humanize()); } picker.SelectedOption = options.IndexOf(FilterType); var ret = await picker.Show(sender); FilterType = options[ret]; }); }
private static string GetStateQueryValue(IssueState state) { switch (state) { case IssueState.Opened: return("opened"); case IssueState.Closed: return("closed"); case IssueState.All: return(""); default: throw new NotSupportedException($"State {state} is not supported"); } }
private async Task <Negotiator> ClearIssue(int issueId, IssueState state) { if (!Security.HasAnyPermissions(User, Permissions.Administrator, Permissions.ManageRequests)) { return(View["Index"]); } var issue = await IssuesService.GetAsync(issueId); var toRemove = issue.Issues.FirstOrDefault(x => x.Issue == state); issue.Issues.Remove(toRemove); var result = await IssuesService.UpdateIssueAsync(issue); return(result ? await Details(issueId) : View["Index"]); }
public static List <Issue> issues(this API_GitHub_Issues gitHubIssues, IssueState state) { if (gitHubIssues.LoggedIn.isFalse()) { return(new List <Issue>()); } gitHubIssues.refreshCacher(); var issues = gitHubIssues.IssuesAPI.List(gitHubIssues.Repository, "", state) .toList(); if (issues.isNull()) { "There was a problem fetching the issues from repository {0}".error(gitHubIssues.Repository); return(new List <Issue>()); } "There were {0} issues with state {1} fetched from repository {2}".info(issues.size(), state, gitHubIssues.Repository); return(issues); }
/// <summary> /// Reports the issue. /// Comment can be null if the <c>IssueState != Other</c> /// </summary> /// <param name="requestId">The request identifier.</param> /// <param name="issue">The issue.</param> /// <param name="comment">The comment.</param> /// <returns></returns> private async Task <Response> ReportIssue(int requestId, IssueState issue, string comment) { if (!Security.HasPermissions(User, Permissions.ReportIssue)) { return(Response.AsJson(new JsonResponseModel { Result = false, Message = "Sorry, you do not have the correct permissions to report an issue." })); } var originalRequest = await Service.GetAsync(requestId); if (originalRequest == null) { return(Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" })); } originalRequest.Issues = issue; originalRequest.OtherMessage = !string.IsNullOrEmpty(comment) ? $"{Username} - {comment}" : string.Empty; var result = await Service.UpdateRequestAsync(originalRequest); var model = new NotificationModel { User = Username, NotificationType = NotificationType.Issue, Title = originalRequest.Title, DateTime = DateTime.Now, Body = issue == IssueState.Other ? comment : issue.ToString().ToCamelCaseWords(), ImgSrc = originalRequest.Type == RequestType.Movie ? $"https://image.tmdb.org/t/p/w300/{originalRequest.PosterPath}" : originalRequest.PosterPath }; await NotificationService.Publish(model); return(Response.AsJson(result ? new JsonResponseModel { Result = true } : new JsonResponseModel { Result = false, Message = "Could not add issue, please try again or contact the administrator!" })); }
public void ChangeState(string projectSlug, string issues, IssueState state) { var project = session.Query <Project>().FirstOrDefault(p => p.Slug == projectSlug); var issueIds = issues.Split(','); using (var transaction = session.BeginTransaction()) { foreach (var issueId in issueIds.Select(int.Parse)) { var issue = session.Query <Issue>().FirstOrDefault(i => i.Number == issueId && i.Project == project); issue.ChangeState(CurrentUser, state); session.SaveOrUpdate(issue); } transaction.Commit(); } RedirectToReferrer(); }
public void RetrievingAnIssue(IssueState issue, Issue fakeIssue) { "Given an existing issue". f(() => { fakeIssue = FakeIssues.FirstOrDefault(); MockIssueStore.Setup(i => i.FindAsync("1")).Returns(Task.FromResult(fakeIssue)); }); "When it is retrieved". f(() => { Request.RequestUri = _uriIssue1; Response = Client.SendAsync(Request).Result; issue = Response.Content.ReadAsAsync <IssueState>().Result; }); "Then a '200 OK' status is returned". f(() => Response.StatusCode.ShouldEqual(HttpStatusCode.OK)); "Then it is returned". f(() => issue.ShouldNotBeNull()); "Then it should have an id". f(() => issue.Id.ShouldEqual(fakeIssue.Id)); "Then it should have a title". f(() => issue.Title.ShouldEqual(fakeIssue.Title)); "Then it should have a description". f(() => issue.Description.ShouldEqual(fakeIssue.Description)); "Then it should have a state". f(() => issue.Status.ShouldEqual(Enum.GetName(typeof(IssueStatus), fakeIssue.Status))); "Then it should have a 'self' link". f(() => { var link = issue.Links.FirstOrDefault(l => l.Rel == IssueLinkFactory.Rels.Self); link.ShouldNotBeNull(); link.Href.AbsoluteUri.ShouldEqual("http://localhost/issue/1"); }); "Then it should have a transition link". f(() => { var link = issue.Links.FirstOrDefault(l => l.Rel == IssueLinkFactory.Rels.IssueProcessor && l.Action == IssueLinkFactory.Actions.Transition); link.ShouldNotBeNull(); link.Href.AbsoluteUri.ShouldEqual("http://localhost/issueprocessor/1?action=transition"); }); }
public IHttpActionResult Post(int boardId, IssueStateModel postedModel) { var previousMaxOrderValue = Context.IssueStates .Where(x => x.BoardId == boardId) .Max(x => x.Order); var state = new IssueState { Name = postedModel.Name, BoardId = boardId, Order = previousMaxOrderValue + 1 }; Context.IssueStates.Add(state); Context.SaveChanges(); ConnectionManager.BroadcastAddState(Result.ToModel(state)); return(Result.Created(state)); }
public MyIssuesFilterViewModel(IActionMenuFactory actionMenu) { Title = "Filter"; State = IssueState.Open; SortType = IssueSort.None; FilterType = IssueFilterState.All; SaveCommand = ReactiveCommand.CreateAsyncTask(_ => Task.FromResult(new MyIssuesFilterModel(FilterType, State, SortType, Labels, Ascending))); SaveCommand.Subscribe(_ => DismissCommand.ExecuteIfCan()); DismissCommand = ReactiveCommand.Create().WithSubscription(_ => Dismiss()); SelectStateCommand = ReactiveCommand.CreateAsyncTask(async sender => { var options = Enum.GetValues(typeof(IssueState)).Cast<IssueState>().ToList(); var picker = actionMenu.CreatePicker(); foreach (var option in options) picker.Options.Add(option.Humanize()); picker.SelectedOption = options.IndexOf(State); var ret = await picker.Show(sender); State = options[ret]; }); SelectSortCommand = ReactiveCommand.CreateAsyncTask(async sender => { var options = Enum.GetValues(typeof(IssueSort)).Cast<IssueSort>().ToList(); var picker = actionMenu.CreatePicker(); foreach (var option in options) picker.Options.Add(option.Humanize()); picker.SelectedOption = options.IndexOf(SortType); var ret = await picker.Show(sender); SortType = options[ret]; }); SelectFilterTypeCommand = ReactiveCommand.CreateAsyncTask(async sender => { var options = Enum.GetValues(typeof(IssueFilterState)).Cast<IssueFilterState>().ToList(); var picker = actionMenu.CreatePicker(); foreach (var option in options) picker.Options.Add(option.Humanize()); picker.SelectedOption = options.IndexOf(FilterType); var ret = await picker.Show(sender); FilterType = options[ret]; }); }
public void ExportCsv(string projectSlug, string[] selectedLabels, IssueState state, string issues) { var project = session.Query <Project>().FirstOrDefault(p => p.Slug == projectSlug); if (Request.Params["state"] == null) { state = CurrentUser.DefaultState; } var items = project.Issues; if (string.IsNullOrEmpty(issues)) { if (selectedLabels.Length > 0) { items = items.Where( i => i.Labels.Select(l => l.Name).Intersect(selectedLabels).Count() == selectedLabels.Length).ToList(); } } else { items = items.Where(i => issues.Split(',').Contains(i.Number.ToString())).ToList(); } var csv = CsvHelper.IssuesCsv(project, items); CancelView(); Response.ClearContent(); Response.Clear(); var filename = string.Format("issues_{0}_{1:yyyyMMdd_hhmm}.csv", project.Name, DateTime.Now); Response.AppendHeader("content-disposition", string.Format("attachment; filename={0}", filename)); Response.ContentType = "application/csv"; var byteArray = Encoding.Default.GetBytes(csv); var stream = new MemoryStream(byteArray); Response.BinaryWrite(stream); }
public void RetrievingAClosedIssue(Issue fakeIssue, IssueState issue) { "Given an existing closed issue". f(() => { fakeIssue = FakeIssues.Single(i => i.Status == IssueStatus.Closed); MockIssueStore.Setup(i => i.FindAsync("2")).Returns(Task.FromResult(fakeIssue)); }); "When it is retrieved". f(() => { Request.RequestUri = _uriIssue2; issue = Client.SendAsync(Request).Result.Content.ReadAsAsync <IssueState>().Result; }); "Then it should have a 'open' action link". f(() => { var link = issue.Links.FirstOrDefault(l => l.Rel == IssueLinkFactory.Rels.IssueProcessor && l.Action == IssueLinkFactory.Actions.Open); link.ShouldNotBeNull(); link.Href.AbsoluteUri.ShouldEqual("http://localhost/issueprocessor/2?action=open"); }); }
public RepositoryIssuesFilterViewModel Init(string repositoryOwner, string repositoryName, IssuesFilterModel model) { RepositoryOwner = repositoryOwner; RepositoryName = repositoryName; Assignee = model.Assignee; Creator = model.Creator; Milestone = model.Milestone; Labels = model.Labels; Mentioned = model.Mentioned; SortType = model.SortType; State = model.IssueState; Ascending = model.Ascending; return this; }
public async Task SetDefault(bool open, string assignee = null) { Creator = null; Mentioned = null; Assignees.Selected = assignee == null ? null : (await _userGet.Value); Milestones.Selected = null; Labels.Selected = null; Ascending = false; SortType = CodeHub.Core.Filters.IssueSort.None; State = open ? IssueState.Open : IssueState.Closed; SaveCommand.ExecuteIfCan(); }
public RepositoryIssuesFilterViewModel(ISessionService sessionService, IActionMenuFactory actionMenu) { Title = "Filter"; State = IssueState.Open; SortType = CodeHub.Core.Filters.IssueSort.None; _userGet = new Lazy<Task<User>>(sessionService.GitHubClient.User.Current); SaveCommand = ReactiveCommand.Create().WithSubscription(_ => Dismiss()); this.WhenAnyValue(x => x.Milestones.Selected) .Select(x => x?.Title) .ToProperty(this, x => x.MilestoneString, out _milestoneString); this.WhenAnyValue(x => x.Assignees.Selected) .Select(x => x?.Login) .ToProperty(this, x => x.AssigneeString, out _assigneeString); this.WhenAnyValue(x => x.Labels.Selected) .Select(x => x ?? new List<Label>()) .Select(x => string.Join(",", x.Select(y => y.Name))) .ToProperty(this, x => x.LabelsString, out _labelsString); var getAssignees = new Lazy<Task<IReadOnlyList<User>>>(() => sessionService.GitHubClient.Issue.Assignee.GetAllForRepository(RepositoryOwner, RepositoryName)); var getMilestones = new Lazy<Task<IReadOnlyList<Milestone>>>(() => sessionService.GitHubClient.Issue.Milestone.GetAllForRepository(RepositoryOwner, RepositoryName)); var getLables = new Lazy<Task<IReadOnlyList<Label>>>(() => sessionService.GitHubClient.Issue.Labels.GetAllForRepository(RepositoryOwner, RepositoryName)); Assignees = new IssueAssigneeViewModel(() => getAssignees.Value); Milestones = new IssueMilestonesViewModel(() => getMilestones.Value); Labels = new IssueLabelsViewModel(() => getLables.Value); SelectAssigneeCommand = ReactiveCommand.Create(); SelectMilestoneCommand = ReactiveCommand.Create(); SelectLabelsCommand = ReactiveCommand.Create(); SelectStateCommand = ReactiveCommand.CreateAsyncTask(async sender => { var options = Enum.GetValues(typeof(IssueState)).Cast<IssueState>().ToList(); var picker = actionMenu.CreatePicker(); foreach (var option in options) picker.Options.Add(option.Humanize()); picker.SelectedOption = options.IndexOf(State); var ret = await picker.Show(sender); State = options[ret]; }); SelectSortCommand = ReactiveCommand.CreateAsyncTask(async sender => { var options = Enum.GetValues(typeof(CodeHub.Core.Filters.IssueSort)).Cast<CodeHub.Core.Filters.IssueSort>().ToList(); var picker = actionMenu.CreatePicker(); foreach (var option in options) picker.Options.Add(option.Humanize()); picker.SelectedOption = options.IndexOf(SortType); var ret = await picker.Show(sender); SortType = options[ret]; }); }
public IssueResponse[] List(string repository, string owner, IssueState issueState) { var state = issueState == IssueState.Open ? "open" : "closed"; var url = GetPathByDefault(repository, owner, "?state={0}", state); return ConsumeJsonUrl<IssueResponse[]>(url); }
public MyIssuesFilterViewModel Init(MyIssuesFilterModel model) { Ascending = model.Ascending; FilterType = model.FilterType; Labels = model.Labels; State = model.Open; SortType = model.SortType; return this; }