private async void RejectAction(PengajuanItem obj) { if (IsBusy) { return; } try { object result = null; if (await Account.UserInRole(UserType.Gate)) { result = await GateService.Reject(Model.Id, Items.SelectMany(x => x.Items).ToList()); } else { result = await ApprovalService.Reject(Model.Id, Items.SelectMany(x => x.Items).ToList()); } if (result != null) { MessagingCenter.Send(new MessagingCenterAlert { Title = "Info", Message = "Berhasil !", Cancel = "OK" }, "message"); IsBusy = false; MessagingCenter.Send(Model, "approve"); await Shell.Current.GoToAsync($"//Home"); } else { throw new SystemException("Gagal... !, Periksa Kembali Data Anda"); } } catch (Exception ex) { MessagingCenter.Send(new MessagingCenterAlert { Title = "Error", Message = ex.Message, Cancel = "OK" }, "message"); IsBusy = false; } }
public async Task CallRejectOnApprovalServiceForLatestRevision() { // Arrange const ApprovalType approvalType = ApprovalType.IPM; var participantId = Guid.NewGuid(); var approverRoleId = Guid.NewGuid(); var cost = MockCost(); var approval = new Approval { CostStageRevisionId = cost.LatestCostStageRevision.Id, Type = approvalType, ApprovalMembers = new List <ApprovalMember> { new ApprovalMember { MemberId = User.Id } } }; foreach (var member in approval.ApprovalMembers) { member.Approval = approval; } cost.LatestCostStageRevision.Approvals = new List <Approval> { approval }; EFContext.Approval.Add(approval); EFContext.UserUserGroup.Add(new UserUserGroup { UserId = participantId, Id = Guid.NewGuid(), UserGroup = new UserGroup { ObjectId = cost.Id, Id = Guid.NewGuid(), RoleId = approverRoleId, } }); EFContext.Role.Add(new Role { Id = approverRoleId, Name = Roles.CostApprover }); EFContext.SaveChanges(); cost.Status = CostStageRevisionStatus.Approved; // Act var response = await ApprovalService.Reject(cost.Id, User, BuType.Pg, null); // Assert response.Should().NotBeNull(); response.Success.Should().BeTrue(); PermissionServiceMock.Verify(p => p.RevokeApproverAccess(cost.OwnerId, cost.Id, It.IsAny <IEnumerable <CostUser> >()), Times.Once); PermissionServiceMock.Verify(p => p.GrantCostPermission(cost.Id, Roles.CostViewer, It.IsAny <IEnumerable <CostUser> >(), BuType.Pg, It.IsAny <Guid?>(), true), Times.Once); }