public CommitViewModel(Guid repositoryId) { _repositoryId = repositoryId; _gitManager = new GitManager(); _branchService = new BranchService(); _commitService = new CommitService(); _branches = new ObservableCollection <Branch>(_branchService.GetBranches(_repositoryId)); _commits = new ObservableCollection <CommitDto>(_branchService.GetBranches(_repositoryId).CreateCommitsDto()); _changedFiles = new ObservableCollection <string>(_gitManager.GitStatusAsync(_repositoryId).Result); _stage = new ObservableCollection <string>(); _visibility = Visibility.Hidden; _mergeVisibility = Visibility.Hidden; Color = Brushes.Blue; ColorPush = Brushes.Blue; Task.Run(async() => { HeadBranch = await _gitManager.NameHeadBranch(_repositoryId); }); Task.Run(async() => { var result = await _gitManager.IsExistPullAsync(_repositoryId).ConfigureAwait(false); if (!result) { Color = Brushes.Red; } }); }
private void FillDropDown() { ddlFindBranch.DataSource = BranchService.GetBranches(); ddlFindBranch.DataTextField = "Name"; ddlFindBranch.DataValueField = "ID"; ddlFindBranch.DataBind(); }
[UseCaseAuthorize("dir_view_branches", "dir_edit_users")] //If you can edit a user you need a list of branches public async Task <IActionResult> Index(string filters = null) { var scope = AuthenticationService.GetScope(User, User.IsSuperAdmin()); var queryOptions = new BranchQueryOptions(scope, filters); var pagedItems = await BranchService.GetBranches(queryOptions); return(Ok(pagedItems)); }
private void FillDropDown() { ddlFindBranch.DataSource = BranchService.GetBranches(); ddlFindBranch.DataTextField = "Name"; ddlFindBranch.DataValueField = "ID"; ddlFindBranch.DataBind(); //cboSupplier.DataSource = SupplierService.GetSuppliers(); //cboSupplier.DataTextField = "Name"; //cboSupplier.DataValueField = "ID"; //cboSupplier.DataBind(); //cboSupplier.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem(String.Empty)); }
// GET api/<controller> public IHttpActionResult Get() { IHttpActionResult result = null; BranchService service = new BranchService(); IEnumerable <Branch> branches = service.GetBranches(); if (branches.Count() > 0) { result = Ok(branches); } else { result = NotFound(); } return(result); }
public void TestGetProcessBranches() { //Arrange manager.DatabaseConnection(); branch.SetDatabase(manager.GetDatabase()); List <string> branchIds = new List <string>() { "5ce95aab70eb31116c6ca8d6", "5ce95b7970eb31116c6ca8d7" }; //Act branch.ReadFromDatabase(branchIds); string branches = branch.GetBranches(); if (!string.IsNullOrEmpty(branches)) { Assert.Pass("Result: Process branches = " + branches + ", Status Code: " + ((int)StatusCode.Ok).ToString() + " - " + StatusCode.Ok.ToString()); } Assert.Fail(); }
public async Task GetBranches_FilterAndSort() { var options = TestHelper.GetDbContext("GetBranches_FilterAndSort"); var user1 = TestHelper.InsertUserDetailed(options); //Given var orgId1 = Guid.NewGuid(); var orgId2 = Guid.NewGuid(); var branch1 = new BranchEntity { Id = Guid.NewGuid(), OrganisationId = orgId1, Name = "A Branch 1" }; var branch2 = new BranchEntity { Id = Guid.NewGuid(), OrganisationId = orgId2, Name = "B Branch 2" }; var branch3 = new BranchEntity { Id = Guid.NewGuid(), OrganisationId = orgId1, Name = "C Branch 3" }; var branch4 = new BranchEntity { Id = Guid.NewGuid(), OrganisationId = orgId2, Name = "D Branch 4" }; var branch5 = new BranchEntity { Id = Guid.NewGuid(), OrganisationId = orgId1, Name = "E Branch 5" }; var branch6 = new BranchEntity { Id = Guid.NewGuid(), OrganisationId = orgId1, Name = "F Branch 6" }; using (var context = new DataContext(options)) { //Jumbled order context.Branch.Add(branch6); context.Branch.Add(branch1); context.Branch.Add(branch2); context.Branch.Add(branch4); context.Branch.Add(branch5); context.Branch.Add(branch3); context.SaveChanges(); } using (var context = new DataContext(options)) { var auditService = new AuditServiceMock(); var service = new BranchService(context, auditService); //When var scope = TestHelper.GetScopeOptions(user1); scope.IgnoreScope = true; var queryOptions = new BranchQueryOptions(scope, $"organisationId={orgId1.ToString()}"); var actual = await service.GetBranches(queryOptions); //Then Assert.Equal(4, actual.TotalItems); var branches = actual.Items.ToArray(); Assert.Equal(4, branches.Count()); var actual1 = branches[0]; Assert.Equal(branch1.Id, actual1.Id); Assert.Equal(branch1.Name, actual1.Name); var actual2 = branches[1]; Assert.Equal(branch3.Id, actual2.Id); Assert.Equal(branch3.Name, actual2.Name); var actual6 = branches[3]; Assert.Equal(branch6.Id, actual6.Id); Assert.Equal(branch6.Name, actual6.Name); } }