public FileContentResult ListExcel(IDbConnection connection, OrderListRequest request)
        {
            var data   = List(connection, request).Entities;
            var report = new DynamicDataReport(data, request.IncludeColumns, typeof(Columns.OrderColumns));
            var bytes  = new ReportRepository().Render(report);

            return(ExcelContentResult.Create(bytes, "OrderList_" +
                                             DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx"));
        }
        public MainResponse <List <OrderResponseWithRevenue> > ListWithRevenue(OrderListRequest model)
        {
            List <OrderResponseWithRevenue> orderList = _db.Orders
                                                        .Where(x =>
                                                               (!model.OrderStatusId.HasValue || x.OrderStatusId == model.OrderStatusId) &&
                                                               (!model.RecordId.HasValue || x.RecordId == model.RecordId) &&
                                                               (!model.AreaId.HasValue || x.AreaId == model.AreaId) &&
                                                               (!model.ClientId.HasValue || x.ClientId == model.ClientId) &&
                                                               (!model.DriverId.HasValue || x.Record.DriverId == model.DriverId) &&
                                                               (!model.From.HasValue || x.OrderDate >= model.From.Value) &&
                                                               (!model.To.HasValue || x.OrderDate <= model.To.Value)
                                                               )
                                                        .Include(x => x.Record)
                                                        .ThenInclude(x => x.Driver)
                                                        .Include(x => x.Area)
                                                        .Include(x => x.Client)
                                                        .Include(x => x.CreatedBy)
                                                        .Include(x => x.OrderStatus)
                                                        .ToList()
                                                        .Select(e => new OrderResponseWithRevenue
            {
                Id              = e.Id,
                ClientId        = e.ClientId,
                ClientName      = e.Client.ClientFullName,
                CreatedAt       = e.CreatedAt,
                CreatedById     = e.CreatedById,
                CreatedBy       = e.CreatedBy.FullNameAr,
                DeliveryNumber  = e.DeliveryPhoneNumber,
                AreaName        = e.Area.AreaName,
                Address         = e.Address,
                DriverId        = e.Record.DriverId,
                OrderId         = e.OrderNumber,
                DriverName      = e.Record.Driver != null ? e.Record.Driver.DriverFullName: "",
                OrderDate       = e.OrderDate,
                OrderTotalPrice = e.OrderTotalPrice,
                RecordId        = e.RecordId,
                OrderStatusId   = e.OrderStatusId,
                OrderStatusName = e.OrderStatus.StatusName,
                CompanyRevenue  = e.CoompanyRevenue,
                AddedPrice      = e.AddedPrice,
                DriverRevenue   = e.DriverRevenue
            })
                                                        .OrderByDescending(x => x.Id)
                                                        .ToList();

            int totalCount = orderList.Count();

            List <OrderResponseWithRevenue> result = orderList.Skip((model.PageNumber - 1) * model.PageSize).Take(model.PageSize).ToList();

            MainResponse <List <OrderResponseWithRevenue> > finalResponse = new MainResponse <List <OrderResponseWithRevenue> >(result, totalCount);

            return(finalResponse);
        }
        public MainResponse <List <OrderResponse> > ListByPhoneNumber(OrderListRequest model)
        {
            List <OrderResponse> orderList = _db.Orders
                                             .Where(x =>
                                                    (string.IsNullOrEmpty(model.OrderPhoneNumber) || x.DeliveryPhoneNumber == model.OrderPhoneNumber)
                                                    )
                                             .Include(x => x.Record)
                                             .ThenInclude(x => x.Driver)
                                             .Include(x => x.Area)
                                             .Include(x => x.Client)
                                             .ThenInclude(x => x.User)
                                             .Include(x => x.CreatedBy)
                                             .Include(x => x.OrderStatus)
                                             .OrderByDescending(x => x.Id)
                                             .Select(e => new OrderResponse
            {
                Address              = e.Address,
                AreaId               = e.AreaId,
                AreaName             = e.Area.AreaName,
                ClientId             = e.ClientId,
                ClientName           = e.Client.ClientFullName,
                ClientPhoneNumber    = e.Client.MobileNumber,
                ClientLatitude       = e.Client.User.Latitude,
                ClientLongitude      = e.Client.User.Longitude,
                CreatedAt            = e.CreatedAt,
                CreatedById          = e.CreatedById,
                CreatedBy            = e.CreatedBy.FullNameAr,
                DeliveryNumber       = e.DeliveryPhoneNumber,
                DriverId             = e.Record.DriverId,
                OrderId              = e.OrderNumber,
                DriverName           = e.Record.Driver != null ? e.Record.Driver.DriverFullName : "",
                ClientStatus         = e.ClientStatus,
                DriverPhoneNumber    = e.Record.Driver != null ? e.Record.Driver.MobileNumber : "",
                IsActive             = e.IsActive,
                OrderDate            = e.OrderDate,
                OrderItemDescription = e.OrderItemTypeDescription,
                OrderTotalPrice      = e.OrderTotalPrice,
                RecordId             = e.RecordId,
                OrderStatusId        = e.OrderStatusId,
                AddedPrice           = e.AddedPrice,
                OrderStatusName      = e.OrderStatus.StatusName
            })
                                             .ToList();


            int totalCount = orderList.Count();

            List <OrderResponse> result = orderList.Skip((model.PageNumber - 1) * model.PageSize).Take(model.PageSize).ToList();

            MainResponse <List <OrderResponse> > finalResponse = new MainResponse <List <OrderResponse> >(result, totalCount);

            return(finalResponse);
        }
        public async Task <OrderListResponse> Get(OrderListRequest request)
        {
            var orders = _orderDataService.Query.FilterByQuery(request.Query).OrderByDescending(x => x.CreateDateTime)
                         .Include(x => x.Creator);

            return(new OrderListResponse
            {
                Access = ResponseAccess.Granted,
                Items = (await orders.Paginate(request.Query).AsNoTracking().ToListAsync()).MapToViewModel(),
                Count = await orders.LongCountAsync()
            });
        }
Example #5
0
        public void UpdateOrderTest()
        {
            var comment = $"Comment: {DateTime.Now}";
            var request = new OrderListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);

            var order = new Order {
                DocumentNumber = 1, Comments = comment
            };
            var updatedOrder = OrderService.UpdateOrderAsync(request, order).GetAwaiter().GetResult();

            Assert.AreEqual(comment, updatedOrder.Comments);
        }
Example #6
0
 public IActionResult ListWithRevenue([FromBody] OrderListRequest model)
 {
     try
     {
         var result = _orderService.ListWithRevenue(model);
         return(Ok(result));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Example #7
0
 public IActionResult GetCompanyRevenueWithHeaders([FromBody] OrderListRequest model)
 {
     try
     {
         var result = _orderService.GetCompanyRevenueCards(model);
         return(Ok(result));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public CompanyRevenueWithHeadersForCompany GetCompanyRevenueCards(OrderListRequest model)
        {
            Configuration configuration = _db.Configurations.FirstOrDefault();
            long          currentUserId = _principalService.GetUserId();
            long          employeeId    = _db.Employees.FirstOrDefault(x => x.UserId == currentUserId).Id;
            CompanyRevenueWithHeadersForCompany companyRevenueWithHeadersForCompany = new CompanyRevenueWithHeadersForCompany();
            List <OrderResponseWithRevenue>     orderList = _db.Orders
                                                            .Where(x =>
                                                                   (!model.OrderStatusId.HasValue || x.OrderStatusId == model.OrderStatusId) &&
                                                                   (!model.ClientId.HasValue || x.ClientId == model.ClientId) &&
                                                                   (!model.DriverId.HasValue || x.Record.DriverId == model.DriverId) &&
                                                                   (!model.From.HasValue || x.OrderDate == model.From.Value)
                                                                   )
                                                            .Include(x => x.Record)
                                                            .ThenInclude(x => x.Driver)
                                                            .Include(x => x.Area)
                                                            .Include(x => x.Client)
                                                            .Include(x => x.CreatedBy)
                                                            .Include(x => x.OrderStatus)
                                                            .OrderByDescending(x => x.Id)
                                                            .Select(e => new OrderResponseWithRevenue
            {
                Address           = e.Address,
                AreaId            = e.AreaId,
                AreaName          = e.Area.AreaName,
                ClientId          = e.ClientId,
                ClientName        = e.Client.ClientFullName,
                CreatedBy         = e.CreatedBy.FullNameAr,
                DriverId          = e.Record.DriverId,
                OrderId           = e.OrderNumber,
                DriverName        = e.Record.Driver != null ? e.Record.Driver.DriverFullName : "",
                DriverPhoneNumber = e.Record.Driver != null ? e.Record.Driver.MobileNumber : "",
                OrderDate         = e.OrderDate,
                OrderTotalPrice   = e.OrderTotalPrice,
                CompanyRevenue    = e.CoompanyRevenue,
                AddedPrice        = e.AddedPrice,
                DriverRevenue     = e.DriverRevenue,
                OrderStatusName   = e.OrderStatus.StatusName
            })
                                                            .ToList();

            companyRevenueWithHeadersForCompany.TotalCompanyRevenue = (orderList.Sum(x => x.CompanyRevenue));
            companyRevenueWithHeadersForCompany.TotalDriverRevenue  = orderList.Sum(x => x.DriverRevenue);
            companyRevenueWithHeadersForCompany.TotalOrderPrices    = orderList.Sum(x => x.OrderTotalPrice) - companyRevenueWithHeadersForCompany.TotalCompanyRevenue - companyRevenueWithHeadersForCompany.TotalDriverRevenue;;

            int totalCount = orderList.Count();

            List <OrderResponseWithRevenue> result = orderList.Skip((model.PageNumber - 1) * model.PageSize).Take(model.PageSize).ToList();

            companyRevenueWithHeadersForCompany.OrderListWithRevenue = new MainResponse <List <OrderResponseWithRevenue> >(result, totalCount);
            return(companyRevenueWithHeadersForCompany);
        }
Example #9
0
        public void SearchOrdersLastModifiedTest()
        {
            var request = new OrderListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret)
            {
                SearchParameters = new Dictionary <OrderSearchParameters, object> {
                    { OrderSearchParameters.LastModified, "2019-10-09 15:25:31" }
                }
            };

            var orders = OrderService.GetOrdersAsync(request).GetAwaiter().GetResult();

            Assert.IsTrue(orders.Data.Any());
        }
Example #10
0
        public void GetSortedOrders()
        {
            var request = new OrderListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret)
            {
                SortBy = OrdersSortableProperties.DocumentNumber
            };
            var orders = OrderService.GetOrdersAsync(request).GetAwaiter().GetResult().Data.ToList();

            Assert.IsTrue(orders.Count() >= 2);

            var X = Int32.Parse(orders.ElementAt(0).DocumentNumber);
            var Y = Int32.Parse(orders.ElementAt(1).DocumentNumber);

            Assert.IsTrue(X < Y);
        }
Example #11
0
        public override async Task <OrderListReply> GetOrderList(OrderListRequest request, ServerCallContext context)
        {
            var list = await _repository.QueryAllAsync(p => new Order()
            {
                OrderId     = p.OrderId,
                ProductName = p.ProductName,
                Quantity    = p.Quantity,
                UnitPrice   = p.UnitPrice,
                Remark      = p.Remark
            });

            var reply = new OrderListReply();

            reply.Orders.AddRange(list);
            return(reply);
        }
Example #12
0
        public void SearchOrdersTest()
        {
            var request = new OrderListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret)
            {
                SearchParameters = new Dictionary <OrderSearchParameters, object> {
                    { OrderSearchParameters.CustomerName, "Kund" }
                }
            };

            var orders = OrderService.GetOrdersAsync(request).GetAwaiter().GetResult();

            foreach (var order in orders.Data)
            {
                Assert.IsTrue(order.CustomerName.ToLower().Contains("kund"));
            }
        }
Example #13
0
        public void SearchOrdersLastModifiedTest()
        {
            var dateOfThisTest = DateTime.Parse("2019-10-09 15:25:31");
            var halfYearPriorToWhenThisTestWasMade = dateOfThisTest.AddDays(-180);

            var request = new OrderListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret)
            {
                SearchParameters = new Dictionary <OrderSearchParameters, object> {
                    { OrderSearchParameters.LastModified, halfYearPriorToWhenThisTestWasMade }
                }
            };

            var orders = OrderService.GetOrdersAsync(request).GetAwaiter().GetResult();

            Assert.IsTrue(orders.Data.Any());
        }
Example #14
0
        public void GetFilteredOrders()
        {
            var request = new OrderListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret)
            {
                Filter = OrderFilters.Cancelled
            };
            var orders = OrderService.GetOrdersAsync(request).GetAwaiter().GetResult();

            Assert.IsNotNull(orders.Data.ToList());
            Assert.IsTrue(orders.Data.Count() > 0);

            foreach (var order in orders.Data)
            {
                Assert.IsTrue(order.Cancelled == true);
            }
        }
Example #15
0
        public void GetOrdersPaginationTest()
        {
            const int PAGES = 5;

            var request = new OrderListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);

            request.Limit = 10;
            request.Page  = 1;

            var orders = new List <OrderSubset>();
            ListedResourceResponse <OrderSubset> response;

            do
            {
                response = OrderService.GetOrdersAsync(request).GetAwaiter().GetResult();
                orders.AddRange(response.Data);
                request.Page = response.MetaInformation.CurrentPage + 1;
            } while (response.MetaInformation.CurrentPage < PAGES);

            Assert.IsTrue(orders.Count() > 10);
            Assert.IsTrue(response.MetaInformation.CurrentPage == 5);
        }
Example #16
0
        /// <summary>
        /// Get order list with all order properties and all order items. The purpose of this API is to reduce the request count.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="acceptEncoding">Indicates that the client accepts that the response will be compressed to reduce traffic size.</param>
        /// <param name="request"> (optional)</param>
        /// <returns>Task of OrderListFull</returns>
        public async System.Threading.Tasks.Task <OrderListFull> GetOrderListFullAsync(List <string> acceptEncoding, OrderListRequest request = null)
        {
            ApiResponse <OrderListFull> localVarResponse = await GetOrderListFullAsyncWithHttpInfo(acceptEncoding, request);

            return(localVarResponse.Data);
        }
        public override Task <OrderListReply> GetOrderList(OrderListRequest request, ServerCallContext context)
        {
            var reply = new OrderListReply();

            return(Task.FromResult(reply));
        }
Example #18
0
        public HttpResponseMessage testone([FromBody] OrderListRequest request)
        {
            var item = request.AuthorizeAutograph();

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
Example #19
0
        public async Task CanSubscribeToMultipleTopics()
        {
            var listeningTask = new Task(async() =>
            {
                var client = new FortnoxWebSocketClient(this.connectionSettings.ClientSecret);
                await client.Connect();
                await client.AddTenant(this.connectionSettings.AccessToken);
                await client.AddTopic(WebSocketTopic.Articles);
                await client.AddTopic(WebSocketTopic.Orders);
                await client.Subscribe();

                var receivedArticleUpdate = false;
                var receivedOrderUpdate   = false;

                while (!receivedArticleUpdate && !receivedOrderUpdate)
                {
                    var response = await client.Receive();
                    if (response.Type == WebSocketResponseType.EventResponse)
                    {
                        Assert.IsTrue(response.Topic == WebSocketTopic.Articles.ToString() || response.Topic == WebSocketTopic.Orders.ToString());

                        if (response.Topic == WebSocketTopic.Articles.ToString())
                        {
                            receivedArticleUpdate = true;
                        }
                        else if (response.Topic == WebSocketTopic.Orders.ToString())
                        {
                            receivedOrderUpdate = true;
                        }

                        Assert.IsTrue(response.EventType == WebSocketEventType.ArticleUpdated || response.EventType == WebSocketEventType.OrderUpdated);
                        Assert.IsTrue(response.EntityId == "100370" || response.EntityId == "1");

                        if (receivedArticleUpdate && receivedOrderUpdate)
                        {
                            return;
                        }
                    }
                }

                await client.Close();
            }, TaskCreationOptions.LongRunning);

            listeningTask.Start();

            var comment = $"Comment: {DateTime.Now}";
            var request = new OrderListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var order   = new Order {
                DocumentNumber = 1, Comments = comment
            };
            var updatedOrder = OrderService.UpdateOrderAsync(request, order).GetAwaiter().GetResult();

            Assert.AreEqual(comment, updatedOrder.Comments);

            var updatedDescription = $"TestArtikel {DateTime.UtcNow}";
            var article            = new Article {
                Description = updatedDescription, ArticleNumber = "100370"
            };
            var articleRequest = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var updatedArticle = ArticleService.UpdateArticleAsync(articleRequest, article).GetAwaiter().GetResult();

            Assert.AreEqual(updatedDescription, updatedArticle.Description);

            await listeningTask;
        }
        /// <summary>
        /// Get a paginated list of all Orders with all Order and Order Item(s) properties The purpose of this operation is to reduce the amount of request to the API.\\ \\ Previous implmentation of this feature only returned a partial (light) version of the Orders. The purpose of this API is to reduce the number of incoming requests by returning the complete (full) Order and Order Item(s) properties.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="acceptEncoding">Allows the client to indicate wether it accepts a compressed encoding to reduce traffic size</param>
        /// <param name="request"></param>
        /// <returns>ApiResponse of OrderListFull</returns>
        public ApiResponse <OrderListFull> GetOrderListFullWithHttpInfo(List <string> acceptEncoding, OrderListRequest request)
        {
            // verify the required parameter 'acceptEncoding' is set
            if (acceptEncoding == null)
            {
                throw new ApiException(400, "Missing required parameter 'acceptEncoding' when calling MarketplacesOrdersListApi->GetOrderListFull");
            }
            // verify the required parameter 'request' is set
            if (request == null)
            {
                throw new ApiException(400, "Missing required parameter 'request' when calling MarketplacesOrdersListApi->GetOrderListFull");
            }

            var    localVarPath         = "/user/marketplaces/orders/list/full";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (acceptEncoding != null)
            {
                localVarHeaderParams.Add("Accept-Encoding", Configuration.ApiClient.ParameterToString(acceptEncoding));                         // header parameter
            }
            if (request != null && request.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(request); // http body (model) parameter
            }
            else
            {
                localVarPostBody = request; // byte array
            }

            // authentication (api_key) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Ocp-Apim-Subscription-Key")))
            {
                localVarHeaderParams["Ocp-Apim-Subscription-Key"] = Configuration.GetApiKeyWithPrefix("Ocp-Apim-Subscription-Key");
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)Configuration.ApiClient.CallApi(localVarPath,
                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("GetOrderListFull", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <OrderListFull>(localVarStatusCode,
                                                   localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                   (OrderListFull)Configuration.ApiClient.Deserialize(localVarResponse, typeof(OrderListFull))));
        }
Example #21
0
        public RetrieveResponse <OrdersPerStatusResponse> OrdersPerStatus(IDbConnection connection)
        {
            var response = new OrdersPerStatusResponse();

            for (int i = 0; i < 12; i++)
            {
                response.labels.Add(DateTime.Now.AddMonths(-i).ToString("MMMM"));
            }


            var orderStatuses = new OrderStatusesRepository().List(connection, new ListRequest()).Entities;

            foreach (var orderStatus in orderStatuses)
            {
                var dataset = new OrdersPerStatusResponse.Dataset();

                dataset.backgroundColor = orderStatus.BackgroundColor;

                dataset.borderColor = orderStatus.BackgroundColor;

                dataset.label = orderStatus.Name;
                for (int j = 0; j < 12; j++)
                {
                    var firstDayOfMonth = new DateTime(DateTime.Now.AddMonths(-j).Year,
                                                       DateTime.Now.AddMonths(-j).Month, 1);
                    var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);

                    var orderFields   = OrdersRow.Fields;
                    var ordersRequest = new OrderListRequest();
                    ordersRequest.ColumnSelection = ColumnSelection.KeyOnly;
                    ordersRequest.Criteria        = (new Criteria(orderFields.OrderDate.Name) >= firstDayOfMonth
                                                     & new Criteria(orderFields.OrderDate.Name) <= lastDayOfMonth
                                                     & new Criteria(orderFields.OrderStatusId.Name) == orderStatus.OrderStatusId.Value
                                                     & new Criteria(orderFields.IsActive.Name) == 1
                                                     & new Criteria(orderFields.NotReal.Name) == 0

                                                     );

                    var orders = new OrdersRepository().List(connection, ordersRequest).Entities;
                    if (!orders.Any())
                    {
                        dataset.data.Add(Decimal.Zero);
                        continue;
                    }

                    var orderDetailsFields      = OrderDetailsRow.Fields;
                    var orderDetailsListRequest = new ListRequest();
                    orderDetailsListRequest.ColumnSelection = ColumnSelection.Details;

                    orderDetailsListRequest.Criteria =
                        (new Criteria(orderDetailsFields.OrderId.Name).In(orders.Select(o => o.OrderId)));

                    var orderDetails = new OrderDetailsRepository().List(connection, orderDetailsListRequest)
                                       .Entities;

                    var totalForMonth = Decimal.Zero;
                    if (orderDetails.Any())
                    {
                        totalForMonth = orderDetails.Select(od => od.LineTotal).Aggregate((a, b) => a + b) ?? Decimal.Zero;
                    }

                    dataset.data.Add(totalForMonth);
                }

                response.datasets.Add(dataset);
            }



            return(new RetrieveResponse <OrdersPerStatusResponse> {
                Entity = response
            });
        }
Example #22
0
        /// <summary>
        /// Retrieves a list of orders
        /// </summary>
        /// <param name="listRequest">Order List Request object</param>
        /// <returns>Listed Resource Response of Fortnox orders</returns>
        public static async Task <ListedResourceResponse <OrderSubset> > GetOrdersAsync(OrderListRequest listRequest)
        {
            var apiRequest = new FortnoxApiClientRequest <ListedResourceResponse <OrderSubset> >(HttpMethod.Get, listRequest.AccessToken, listRequest.ClientSecret,
                                                                                                 ApiEndpoints.Orders);

            apiRequest.SetFilter(listRequest.Filter?.ToString());
            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));
        }
Example #23
0
        /// <summary>
        /// Get order list without details
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request"> (optional)</param>
        /// <returns>Task of ApiResponse (OrderListLight)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <OrderListLight> > GetOrderListLightAsyncWithHttpInfo(OrderListRequest request = null)
        {
            var    localVarPath         = "/v2/user/marketplaces/orders/list/light";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (request != null && request.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(request); // http body (model) parameter
            }
            else
            {
                localVarPostBody = request; // byte array
            }

            // authentication (api_key) required
            if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("Ocp-Apim-Subscription-Key")))
            {
                localVarHeaderParams["Ocp-Apim-Subscription-Key"] = Configuration.GetApiKeyWithPrefix("Ocp-Apim-Subscription-Key");
            }

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("GetOrderListLight", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <OrderListLight>(localVarStatusCode,
                                                    localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                    (OrderListLight)Configuration.ApiClient.Deserialize(localVarResponse, typeof(OrderListLight))));
        }
Example #24
0
        /// <summary>
        /// Get order list without details
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request"> (optional)</param>
        /// <returns>Task of OrderListLight</returns>
        public async System.Threading.Tasks.Task <OrderListLight> GetOrderListLightAsync(OrderListRequest request = null)
        {
            ApiResponse <OrderListLight> localVarResponse = await GetOrderListLightAsyncWithHttpInfo(request);

            return(localVarResponse.Data);
        }
        public MainResponse <List <OrderResponse> > List(OrderListRequest model)
        {
            DateTime orderDate     = _db.Configurations.FirstOrDefault().OrdersDate;
            long     currentUserId = _principalService.GetUserId();
            long     employeeId    = _db.Employees.FirstOrDefault(x => x.UserId == currentUserId).Id;

            List <OrderResponse> orderList = _db.Orders
                                             .Where(x =>
                                                    (!model.OrderStatusId.HasValue || x.OrderStatusId == model.OrderStatusId) &&
                                                    (!model.RecordId.HasValue || x.RecordId == model.RecordId) &&
                                                    (!model.AreaId.HasValue || x.AreaId == model.AreaId) &&
                                                    (!model.ClientId.HasValue || x.ClientId == model.ClientId) &&
                                                    (!model.DriverId.HasValue || x.Record.DriverId == model.DriverId) &&
                                                    (!model.From.HasValue || x.OrderDate >= model.From.Value) &&
                                                    (!model.To.HasValue || x.OrderDate <= model.To.Value)
                                                    )
                                             .Include(x => x.Record)
                                             .ThenInclude(x => x.Driver)
                                             .Include(x => x.Area)
                                             .Include(x => x.Client)
                                             .ThenInclude(x => x.User)
                                             .Include(x => x.CreatedBy)
                                             .Include(x => x.OrderStatus)
                                             .OrderByDescending(x => x.Id)
                                             .Select(e => new OrderResponse
            {
                Address              = e.Address,
                AreaId               = e.AreaId,
                AreaName             = e.Area.AreaName,
                ClientId             = e.ClientId,
                ClientName           = e.Client.ClientFullName,
                ClientPhoneNumber    = e.Client.MobileNumber,
                ClientLatitude       = e.Client.User.Latitude,
                ClientLongitude      = e.Client.User.Longitude,
                CreatedAt            = e.CreatedAt,
                CreatedById          = e.CreatedById,
                CreatedBy            = e.CreatedBy.FullNameAr,
                DeliveryNumber       = e.DeliveryPhoneNumber,
                DriverId             = e.Record.DriverId,
                OrderId              = e.OrderNumber,
                DriverName           = e.Record.Driver != null ? e.Record.Driver.DriverFullName : "",
                ClientStatus         = e.ClientStatus,
                DriverPhoneNumber    = e.Record.Driver != null ? e.Record.Driver.MobileNumber : "",
                IsActive             = e.IsActive,
                OrderDate            = e.OrderDate,
                OrderItemDescription = e.OrderItemTypeDescription,
                OrderTotalPrice      = e.OrderTotalPrice,
                RecordId             = e.RecordId,
                OrderStatusId        = e.OrderStatusId,
                AddedPrice           = e.AddedPrice,
                OrderStatusName      = e.OrderStatus.StatusName
            })
                                             .ToList();


            int totalCount = orderList.Count();

            List <OrderResponse> result = orderList.Skip((model.PageNumber - 1) * model.PageSize).Take(model.PageSize).ToList();

            MainResponse <List <OrderResponse> > finalResponse = new MainResponse <List <OrderResponse> >(result, totalCount);

            return(finalResponse);
        }
 public ListResponse <MyRow> List(IDbConnection connection, OrderListRequest request)
 {
     return(new MyRepository().List(connection, request));
 }
Example #27
0
        /// <summary>
        /// Get order list with all order properties and all order items. The purpose of this API is to reduce the request count.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="acceptEncoding">Indicates that the client accepts that the response will be compressed to reduce traffic size.</param>
        /// <param name="request"> (optional)</param>
        /// <returns>OrderListFull</returns>
        public OrderListFull GetOrderListFull(List <string> acceptEncoding, OrderListRequest request = null)
        {
            ApiResponse <OrderListFull> localVarResponse = GetOrderListFullWithHttpInfo(acceptEncoding, request);

            return(localVarResponse.Data);
        }
Example #28
0
 public ListResponse <MyRow> List(IDbConnection connection, OrderListRequest request)
 {
     return(new MyListHandler().Process(connection, request));
 }
Example #29
0
        /// <summary>
        /// Get order list without details
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request"> (optional)</param>
        /// <returns>OrderListLight</returns>
        public OrderListLight GetOrderListLight(OrderListRequest request = null)
        {
            ApiResponse <OrderListLight> localVarResponse = GetOrderListLightWithHttpInfo(request);

            return(localVarResponse.Data);
        }