Exemple #1
0
        public void GetUnits()
        {
            var request = new UnitListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var units   = UnitService.GetUnitsAsync(request).GetAwaiter().GetResult();

            Assert.IsTrue(units.Data.ToList().Count > 0);
        }
Exemple #2
0
 public UnitListResponse Execute(UnitListRequest request)
 {
     return(new UnitListResponse()
     {
         Units = (IList <UnitModel>)ServiceHelper.LoadService <IProductionService>().GetAllUnits().Select <UnitInfo, UnitModel>((Func <UnitInfo, UnitModel>)(m => m.ToModel())).ToList <UnitModel>()
     });
 }
Exemple #3
0
        public void GetSortedUnits()
        {
            var request = new UnitListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret)
            {
                SortBy = UnitSortableProperties.Code
            };
            var units = UnitService.GetUnitsAsync(request).GetAwaiter().GetResult();

            Assert.IsTrue(units.Data.ToList().First().Code.StartsWith("förp"));
        }
Exemple #4
0
        public void SearchUnits()
        {
            var request = new UnitListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret)
            {
                SearchParameters = new Dictionary <UnitSearchParameters, object> {
                    { UnitSearchParameters.LastModified, DateTime.Today.ToString("yyyy-MM-dd") }
                }
            };

            var units = UnitService.GetUnitsAsync(request).GetAwaiter().GetResult();

            Assert.IsFalse(units.Data.Any());
        }
Exemple #5
0
        /// <summary>
        /// 获取兵种信息
        /// </summary>
        public int Call_UnitList(UnitListRequest request)
        {
            UnitListResponse response = new UnitListResponse();

            response.success = true;
            response.pid     = CurrentSession.UserId;
            response.units   = new List <UnitInfo>();
            var units = this.CurrentSession.GetBindPlayer().Units;

            foreach (var unit in units)
            {
                var u = this.ToUnitInfo(unit);
                response.units.Add(u);
            }
            CurrentSession.SendAsync(response);
            return(0);
        }
Exemple #6
0
        public static async Task <ListedResourceResponse <Unit> > GetUnitsAsync(UnitListRequest listRequest)
        {
            var apiRequest = new FortnoxApiClientRequest <ListedResourceResponse <Unit> >(HttpMethod.Get, listRequest.AccessToken, listRequest.ClientSecret,
                                                                                          ApiEndpoints.Units);

            apiRequest.SetSortOrder(listRequest.SortBy?.ToString(), listRequest.SortOrder.ToString());
            apiRequest.SetPageAndLimit(listRequest.Page, listRequest.Limit);

            if (listRequest.SearchParameters == null)
            {
                return(await FortnoxAPIClient.CallAsync(apiRequest));
            }

            foreach (var param in listRequest.SearchParameters)
            {
                apiRequest.AddSearchParam(param.Key.ToString().ToLower(), param.Value);
            }

            return(await FortnoxAPIClient.CallAsync(apiRequest));
        }
Exemple #7
0
        public void GetUnitsPaginationTest()
        {
            var request = new UnitListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);

            request.Limit = 50;
            request.Page  = 1;

            var units = new List <Unit>();
            ListedResourceResponse <Unit> response;
            var pages = 0;

            do
            {
                pages++;
                response = UnitService.GetUnitsAsync(request).GetAwaiter().GetResult();
                units.AddRange(response.Data);
                request.Page = response.MetaInformation.CurrentPage + 1;
            } while (response.MetaInformation.CurrentPage != response.MetaInformation.TotalPages);

            Assert.IsTrue(units.Count > 0);
        }
Exemple #8
0
 public UnitListRequest1(UnitListRequest unitListRequest) => UnitListRequest = unitListRequest;