public DeptListVM() { ResultList = new List <ListRow>(); Input = new ListInput(5); Input.OrderExpression = Dept.DefaultSortString; EditInput = new DeptEditVM.EditInput(); }
public ApiResult <ListOutput> List([FromQuery] ListInput parameter) { var rewardInput = new RewardInput { PageIndex = parameter.PageIndex, UserId = parameter.LoginUserId, PageSize = parameter.PageSize }; var model = Resolve <IRewardService>().GetViewRewardPageList(rewardInput, HttpContext); var apiOutput = new ListOutput { TotalSize = model.PageCount, StyleType = 1 }; var users = Resolve <IUserService>().GetList(); foreach (var item in model) { var orderUser = users.FirstOrDefault(u => u.Id == item.OrderUserId); var apiData = new ListItem { Id = item.Reward.Id, Intro = $"{item.Reward.CreateTime:yyyy-MM-dd hh:ss}", Title = $"{orderUser.UserName}", Image = Resolve <IApiService>().ApiUserAvator((item.OrderUser?.Id).ConvertToLong()), Url = $"/pages/index?path=share_show&id={item.Reward.Id}", Extra = item.Reward.Amount.ToStr() }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); }
private IEnumerable <CompletedEvent> GetOrderedCompletedEventsWithPagination(ListInput infoModel, Expression <Func <CompletedEvent, bool> > criteria, string periodType, params Expression <Func <CompletedEvent, object> >[] includeProperties) { switch (infoModel.OrderBy) { case OrderBy.PatientName: return(GetOrderedByDirectionAndPagination(infoModel, criteria, e => e.Period.Pathway.Patient.Name, periodType, includeProperties)); case OrderBy.EventDescription: return(GetOrderedByDirectionAndPagination(infoModel, criteria, e => e.Name.Code.ToString(), periodType, includeProperties)); case OrderBy.Specialty: return(GetOrderedByDirectionAndPagination(infoModel, criteria, e => e.Clinician.Specialty.Name, periodType, includeProperties)); case OrderBy.Clinician: return(GetOrderedByDirectionAndPagination(infoModel, criteria, e => e.Clinician.Name, periodType, includeProperties)); case OrderBy.Hospital: return(GetOrderedByDirectionAndPagination(infoModel, criteria, e => e.Clinician.Hospital.Name, periodType, includeProperties)); case OrderBy.DateOfBirth: return(GetOrderedByDirectionAndPagination(infoModel, criteria, e => e.Period.Pathway.Patient.DateOfBirth, periodType, includeProperties)); case OrderBy.Age: return(GetOrderedByDirectionAndPagination(infoModel, criteria, e => e.Period.Pathway.Patient.DateOfBirth, periodType, includeProperties)); case OrderBy.ImportDate: return(GetOrderedByDirectionAndPagination(infoModel, criteria, e => e.EventDate, periodType)); } return(GetCompletedEventsByCriteria(criteria, periodType, includeProperties).ToArray()); }
public void Error_IfParametersAreNull() { var linput = new ListInput(); var param = new Parameters { AwsAccessKeyId = null, AwsSecretAccessKey = " ", BucketName = string.Empty }; var opt = new ListOptions { FullResponse = true }; async Task TestDelegate() { await ListTask.ListObjectsAsync(linput, param, opt, new CancellationToken()); } Assert.That(TestDelegate, Throws.TypeOf <ArgumentNullException>() .With.Message.EndsWith( string.Join(", ", nameof(param.AwsAccessKeyId), nameof(param.AwsSecretAccessKey), nameof(param.BucketName)))); }
public ApiResult <ListOutput> Bill([FromQuery] ListInput parameter) { var moneyTypes = Resolve <IAutoConfigService>().MoneyTypes(); var billApiInput = new BillApiInput { UserId = parameter.LoginUserId, PageIndex = parameter.PageIndex, PageSize = parameter.PageSize }; var billList = Resolve <IFinanceAdminService>().GetApiBillPageList(billApiInput, out var count); var result = new ListOutput { StyleType = 1, //采用第一种样式 TotalSize = count / parameter.PageSize }; foreach (var item in billList.ToList()) { var index = new Random().Next(1, 8); var apiData = new ListItem { Id = item.Id, Intro = $"账后{item.AfterAmount} 时间{item.CreateTime.ToString("yyyy-MM-dd hh:ss")}", Title = $"{moneyTypes.FirstOrDefault(e => e.Id == item.MoneyTypeId)?.Name}-{item.Type.GetDisplayName()}", Image = Resolve <IApiService>().ApiImageUrl($"/assets/mobile/images/icon/demo{index}.png"), Url = $"/finance/bill/view?id={item.Id}".ToClientUrl(ClientType.WapH5), Extra = item.Amount.ToStr() }; result.ApiDataList.Add(apiData); } return(ApiResult.Success(result)); }
public ApiResult <UserOutput> Info(ListInput parameter) { if (parameter.LoginUserId < 1) { return(ApiResult.Failure <UserOutput>($"用户ID不能为{parameter.LoginUserId}!")); } var user = Resolve <IUserService>().GetSingle(parameter.LoginUserId); if (user == null) { return(ApiResult.Failure <UserOutput>($"用户ID={parameter.LoginUserId}没有对应数据记录!")); } var userGrade = Resolve <IAutoConfigService>().GetList <UserGradeConfig>(u => u.Id == user.GradeId); var userDetail = Resolve <IUserDetailService>().GetSingle(parameter.LoginUserId); var userOutput = AutoMapping.SetValue <UserOutput>(user); userOutput.GradeName = userGrade.Count > 0 ? userGrade[0]?.Name : string.Empty; userOutput.Sex = userDetail.Sex.GetDisplayName(); userOutput.ParentUserName = Resolve <IUserService>().GetSingle(u => u.Id == user.ParentId)?.UserName; userOutput.RegionName = Resolve <IRegionService>().GetRegionNameById(userDetail.RegionId); if (!userDetail.Avator.IsNullOrEmpty()) { userOutput.Avator = Resolve <IApiService>().ApiImageUrl(userDetail.Avator); } else { userOutput.Avator = Resolve <IApiService>().ApiImageUrl(@"/wwwroot/static/images/avator/man_64.png"); } return(ApiResult.Success(userOutput)); }
public void ShouldHaveNameAndMessage() { var message = "Message"; var name = "Name"; var consoleRender = Substitute.For <IScreenManager>(); var input = new ListInput(name, message, new string[] { }, consoleRender); input.message.Should().Be(message); input.name.Should().Be(name); }
public void ShouldCallConsoleWriteLine() { var message = "Message"; var name = "Name"; var consoleRender = Substitute.For <IScreenManager>(); var input = new ListInput(name, message, new string[] { "option1", "option2" }, consoleRender); input.Render(); consoleRender.Received().Render(Arg.Any <string[]>(), Arg.Any <string[]>()); }
public void FirstQuestionShouldBeRenderedAsSelected() { var message = "Message"; var name = "Name"; var options = new string[] { "option1", "option2" }; var consoleRender = Substitute.For <IScreenManager>(); var input = new ListInput(name, message, options, consoleRender); var question = input.GetQuestion(); question[1].Should().Be("> option1"); }
public void QuestionShouldReturnMessageAndOptions() { var message = "Message"; var name = "Name"; var options = new string[] { "option1", "option2" }; var consoleRender = Substitute.For <IScreenManager>(); var input = new ListInput(name, message, options, consoleRender); var question = input.GetQuestion(); question.Should().HaveCount(3); question[0].Should().Be("Message"); }
public void Test() { var input = new ListInput() { PointFlag = @"..{0}..{0}..{0}..".ToFormat(Path.DirectorySeparatorChar) }; var cmd = new ListCommand(); cmd.Execute(input); //REVIEW: how do I test the console out put? }
public void Test() { var input = new ListInput() { PointFlag = @"..\..\..\.." }; var cmd = new ListCommand(); cmd.Execute(input); //REVIEW: how do I test the console out put? }
public override Int32Output TestForeachInfiniteLoop(ListInput input) { int i = 1; foreach (var t in input.List) { i++; } return(new Int32Output { Int32Value = i }); }
public static void Run() { var options = new string[] { "Option 1", "Option 2" }; var listInput = new ListInput("option", "Which option?", options); var sureInput = new InputConfirmation("confirm", "Are you sure?"); var inquirer = new Inquirer(listInput, sureInput); inquirer.Ask(); var answer = listInput.Answer(); Console.WriteLine($@"You have selected option: {answer} - {options[Int32.Parse(answer)-1]}"); Console.WriteLine(sureInput.Answer() == "y" ? "And you are sure!" : "And you are not sure!"); Console.ReadKey(); }
public void Error_IfBucketNameIsEmpty() { var linput = new ListInput(); var param = new Parameters { AwsAccessKeyId = "foo", AwsSecretAccessKey = "bar", BucketName = null }; var opt = new ListOptions { FullResponse = true }; async Task TestDelegate() { await ListTask.ListObjectsAsync(linput, param, opt, new CancellationToken()); } Assert.That(TestDelegate, Throws.TypeOf <ArgumentNullException>().With.Message.StartWith("Value cannot be null.")); }
public ApiResult <ListOutput> PayCheckList([FromQuery] ListInput parameter) { var model = Resolve <IPayService>().GetList(u => u.UserId == parameter.LoginUserId).ToList(); var apiOutput = new ListOutput { TotalSize = model.Count() / parameter.PageSize }; foreach (var item in model) { var apiData = new ListItem { Title = $"金额{item.Amount}元", Intro = $"{item.CreateTime.ToString("yyyy-MM-dd hh:ss")}", // Extra = "编号" + item.Serial, Image = Resolve <IApiService>().ApiUserAvator(item.Id), Id = item.Id, Url = $"/pages/user?path=Asset_pay_view&id={item.Id}" }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); }
public ApiResult <ListOutput> List([FromQuery] ListInput parameter) { //var model = Resolve<ITradeService>() // .GetList(u => /*u.UserId == parameter.LoginUserId &&*/ u.Type == TradeType.Recharge).ToList(); //var apiOutput = new ListOutput { // TotalSize = model.Count() / parameter.PageSize //}; //foreach (var item in model) { // var apiData = new ListItem { // Title = $"充值金额{item.Amount}元", // Intro = $"{item.CreateTime.ToString("yyyy-MM-dd hh:ss")}", // Extra = "编号" + item.Serial, // Image = Resolve<IApiService>().ApiUserAvator(item.Id), // Id = item.Id, // Url = $"/pages/user?path=Asset_recharge_view&id={item.Id}" // }; // apiOutput.ApiDataList.Add(apiData); //} // return ApiResult.Success(); return(null); }
public ListInput GetListType() { ListInput type = ListInput.ShortList; bool tryAgain = true; while (tryAgain) { try { Console.Clear(); Console.Write("\nSelect which list of previous 10 games you want to see:" + "\n 1 Short list" + "\n 2 Full details list" + "\n\nSELECTION: "); int listType = int.Parse(Console.ReadLine()); if (listType < 1 || listType > 2) { throw new Exception("\nYou didn't enter either number 1 or 2!"); } else { type = listType == 1 ? ListInput.ShortList : ListInput.FullList; tryAgain = false; } } catch (FormatException) { TextToConsole("\nYou didn't give a valid entry! START AGAIN"); } catch (Exception ex) { TextToConsole(ex.Message); } } return(type); }
/// <summary> /// 列出文件的具体实现 /// </summary> /// <param name="input"></param> /// <returns></returns> public override async Task <ListOutput> ListCoreAsync(ListInput input) { var output = new ListOutput() { Size = input.Size, Start = input.Start }; try { //非首次请求时获取上次保存的分页标记 var marker = ""; if (input.Start > 0) { marker = GetMarker(); } await Task.Run(() => { var req = new ListObjectsRequest(_ossConfig.BucketName) { Marker = marker, //获取超过当前请求数量的数据,如果返回的比请求的多说明有下一页 MaxKeys = input.Size + 1, Prefix = $"{_ossConfig.ObjectNamePrefix}/{input.ListPath}" }; var listResult = _ossClient.ListObjects(req); if (listResult.HttpStatusCode == System.Net.HttpStatusCode.OK) { var items = listResult.ObjectSummaries.ToList(); var returnItems = new List <ListItemOutput>(); returnItems.AddRange(items.Select(p => new ListItemOutput() { //拼接OSS可访问路径 Url = $"{(string.IsNullOrWhiteSpace(_ossConfig.CustomerDomain) ? $"{_ossConfig.BucketName}.{_ossConfig.EndPoint}/{p.Key}" : $"{_ossConfig.CustomerDomain}/{p.Key}")}", Original = Path.GetFileName(p.Key), Key = p.Key })); output.Total = returnItems.Count; if (returnItems.Count > input.Size) { output.Total = input.Start + input.Size + 1; //获取请求数量的数据 returnItems = returnItems.GetRange(0, input.Size); //获取下一页的分页标记 marker = returnItems.Last().Key; } else { //如果当前为最后一页则清除分页标记 marker = ""; } output.List = returnItems; output.State = "SUCCESS"; //保存分页标记用于请求后续数据 SetMarker(marker); } else { throw new UEditorServiceException("列出OSS文件失败"); } });
public TaskItemListVM() { ResultList = new List <ListRow>(); Input = new ListInput(5); }
public ListResult GetList(ListInput Inpurt) { return(_coreModel.GetList(Inpurt.OrganizationID)); }
public IEnumerable <CompletedEvent> Get(Expression <Func <CompletedEvent, bool> > criteria, string periodType = null, ListInput infoModel = null, params Expression <Func <CompletedEvent, object> >[] includeProperties) { if (infoModel == null || ((infoModel.OrderBy == null || infoModel.OrderDirection == null) && (infoModel.Index == null || infoModel.PageCount == null))) { return(GetCompletedEventsByCriteria(criteria, periodType, includeProperties) .ToArray()); } if (infoModel.OrderBy != null && infoModel.OrderDirection != null) { if (infoModel.Index == null || infoModel.PageCount == null) { return(GetOrderedCompletedEvents(infoModel.OrderBy, infoModel.OrderDirection, criteria, periodType, includeProperties)); } return(GetOrderedCompletedEventsWithPagination(infoModel, criteria, periodType, includeProperties)); } return(GetCompletedEventsByCriteria(criteria, periodType, includeProperties) .OrderBy(completedEvent => completedEvent.EventDate) .Skip((infoModel.Index.Value - 1) * infoModel.PageCount.Value) .Take(infoModel.PageCount.Value) .ToArray()); }
private IEnumerable <CompletedEvent> GetCriteriaDescendingWithPagination <TKey>(ListInput infoModel, Expression <Func <CompletedEvent, bool> > criteria, Expression <Func <CompletedEvent, TKey> > orderCriteria, string periodType, params Expression <Func <CompletedEvent, object> >[] includeProperties) { return(GetCompletedEventsByCriteria(criteria, periodType, includeProperties) .OrderByDescending(orderCriteria) .Skip((infoModel.Index.Value - 1) * infoModel.PageCount.Value) .Take(infoModel.PageCount.Value) .ToArray()); }
private IEnumerable <CompletedEvent> GetOrderedByDirectionAndPagination <TKey>(ListInput infoModel, Expression <Func <CompletedEvent, bool> > criteria, Expression <Func <CompletedEvent, TKey> > orderCriteria, string periodType, params Expression <Func <CompletedEvent, object> >[] includeProperties) { if (infoModel.OrderDirection == OrderDirection.Ascending) { if (infoModel.OrderBy == OrderBy.Age) { return(GetCriteriaDescendingWithPagination(infoModel, criteria, orderCriteria, periodType, includeProperties)); } return(GetCriteriaAscendingWithPagination(infoModel, criteria, orderCriteria, periodType, includeProperties)); } if (infoModel.OrderBy == OrderBy.Age) { return(GetCriteriaAscendingWithPagination(infoModel, criteria, orderCriteria, periodType, includeProperties)); } return(GetCriteriaDescendingWithPagination(infoModel, criteria, orderCriteria, periodType, includeProperties)); }
public MemberNoteListVM() { ResultList = new List <ListRow>(); Input = new ListInput(5); }
public UserListVM() { ResultList = new List <ListRow>(); Input = new ListInput(5); }
private static Either <ParsingError <ListInput <T> >, ParsingResult <ListInput <T>, T> > Read <T>(ListInput <T> input) => (input.Position < input.Items.Count) switch { true => Right(Result(input.Items[input.Position], input with {