public List <PurchaseOrderContract> GetPurchaseOrders(long salesAgentId)
        {
            var queryRequest = new QueryRequestModel(_dbId);

            queryRequest.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18
            };
            queryRequest.Where   = $"{{11.EX.{salesAgentId}}}";
            queryRequest.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", queryRequest);

            var purchaseOrders = new List <PurchaseOrderContract>();

            if (result.Data != null)
            {
                foreach (var data in result.Data)
                {
                    purchaseOrders.Add(new PurchaseOrderContract(data));
                }
            }

            return(purchaseOrders);
        }
Beispiel #2
0
        public SalesAgentContract GetSalesAgent(long recordId)
        {
            var query = new QueryRequestModel(_dbId);

            query.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11, 12
            };
            query.Where   = $"{{3.EX.{recordId}}}";
            query.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", query);

            if (result.Data.Any())
            {
                var data = result.Data.First();
                return(new SalesAgentContract(data));
            }

            return(null);
        }
        public PurchaseOrderContract GetPurchaseOrder(long recordId, long salesAgentId)
        {
            var queryRequest = new QueryRequestModel(_dbId);

            queryRequest.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18
            };
            queryRequest.Where   = $"{{3.EX.{recordId}}}AND{{11.EX.{salesAgentId}}}";
            queryRequest.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", queryRequest);

            if (result.Data != null)
            {
                var data = result.Data.First();
                return(new PurchaseOrderContract(data));
            }

            return(null);
        }
Beispiel #4
0
        public List <CustomerContract> GetCustomers(string query)
        {
            var queryRequest = new QueryRequestModel(_dbId);

            queryRequest.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11
            };

            if (!string.IsNullOrEmpty(query))
            {
                queryRequest.Where = $"{{6.CT.'{query}'}}";
            }
            queryRequest.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", queryRequest);

            var customers = new List <CustomerContract>();

            if (result.Data != null)
            {
                foreach (var data in result.Data)
                {
                    customers.Add(new CustomerContract(data));
                }
            }

            return(customers);
        }
Beispiel #5
0
        public CustomerContract GetCustomer(long recordId)
        {
            var queryRequest = new QueryRequestModel(_dbId);

            queryRequest.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11
            };
            queryRequest.Where   = $"{{3.EX.{recordId}}}";
            queryRequest.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", queryRequest);

            if (result.Data != null)
            {
                var data = result.Data.First();
                return(new CustomerContract(data));
            }

            return(null);
        }
        public List <AttendanceLogContract> GetAttendanceLogs(long employeeRecordId)
        {
            var queryRequest = new QueryRequestModel(_dbId);

            queryRequest.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11, 12, 13, 14
            };
            queryRequest.Where   = $"{{11.EX.{employeeRecordId}}}";
            queryRequest.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", queryRequest);

            var logs = new List <AttendanceLogContract>();

            if (result.Data != null)
            {
                foreach (var data in result.Data)
                {
                    logs.Add(new AttendanceLogContract(data));
                }
            }

            return(logs);
        }
        public AttendanceLogContract GetAttendanceLog(long recordId, long employeeRecordId)
        {
            var queryRequest = new QueryRequestModel(_dbId);

            queryRequest.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11, 12, 13, 14
            };
            queryRequest.Where   = $"{{3.EX.{recordId}}}AND{{11.EX.{employeeRecordId}}}";
            queryRequest.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", queryRequest);

            if (result.Data != null)
            {
                var data = result.Data.First();
                return(new AttendanceLogContract(data));
            }

            return(null);
        }
        public long?Login(string employeeId, string accessCode)
        {
            var query = new QueryRequestModel(_dbId);

            query.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11, 12
            };
            query.Where   = $"{{9.EX.'{employeeId}'}}AND{{10.EX.'{accessCode}'}}";
            query.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", query);

            if (result.Data.Any())
            {
                return((long)result.Data.First()["3"].Value);
            }

            return(null);
        }
Beispiel #9
0
 public Message SaveQuery([FromBody] QueryRequestModel request)
 {
     QueryHelper.SaveQueryHelper(request.Name, request.Query, request.GroupId);
     return(new SuccessMessage
     {
         Data = null,
         MessageText = "Query Saved"
     });
 }
Beispiel #10
0
        public async Task <IHttpActionResult> Query([FromUri] string[] sort, [FromBody] QueryRequestModel filter)
        {
            var queryResult = await appManager.Query(sort, filter);

            if (queryResult == null)
            {
                return(BadRequest("Invalid query"));
            }
            if (queryResult.Count == 0)
            {
                return(Ok("Your query didn't produce anything"));
            }
            return(Ok(queryResult));
        }
Beispiel #11
0
        public async Task <List <ContactResponseModel> > Query(string[] sorts, QueryRequestModel qrm)
        {
            var fullName    = !string.IsNullOrEmpty(qrm.FullName) ? qrm.FullName : "%";
            var companyName = !string.IsNullOrEmpty(qrm.CompanyName) ? qrm.CompanyName : "%";
            var position    = !string.IsNullOrEmpty(qrm.Position) ? qrm.Position : "%";
            var country     = !string.IsNullOrEmpty(qrm.Country) ? qrm.Country : "%";
            var email       = !string.IsNullOrEmpty(qrm.Email) ? qrm.Email : "%";
            var queryString = "select * from Contacts " +
                              $"where fullname like '{fullName}' " +
                              $"and companyname like '{companyName}' " +
                              $"and position like '{position}' " +
                              $"and country like '{country}' " +
                              $"and email like '{email}'";

            if (sorts != null && sorts.Length != 0) // order by
            {
                queryString += " order by ";
                queryString  = sorts.Aggregate(queryString, (current, sort) => current + $"{sort.Replace('_', ' ')},");
                queryString  = queryString.TrimEnd(',');
            }
            var rows = await db.Contacts.SqlQuery(queryString).ToListAsync();

            return(rows.Select(x => modelFactory.CreateContactResponseModel(x)).ToList());
        }
        public ActionResult Execute(QueryRequestModel request)
        {
            try
            {
                var temp = new User
                {
                    Username = "******",
                    Email    = "*****@*****.**"
                };
                var user = DataContext.Users.FirstOrDefault(x => x.Username == temp.Username);
                if (user == null)
                {
                    DataContext.Users.Add(temp);
                    DataContext.SaveChanges();
                }



                var query = new SqlQuery
                {
                    Sql = request.Query
                };
                IQueryResult result = GetUserDataSource().Execute(query);
                var          model  = QueryResultViewModel.Generate(result);

                //var json = JsonResult(model);
                //return json;

                var view = PartialView("_ExecuteResult", model);
                return(view);
            }
            catch (Exception ex)
            {
                return(Error(ex));
            }
        }
        public List <ProductContract> GetProducts(string query)
        {
            var queryRequest = new QueryRequestModel("bqy89m7q2");

            queryRequest.Select = new List <long>()
            {
                3, 6, 7, 8, 9, 10, 11
            };

            if (!string.IsNullOrEmpty(query))
            {
                queryRequest.Where = $"{{6.CT.'{query}'}}OR{{7.CT.'{query}'}}";
            }

            queryRequest.GroupBy = new List <QueryRequestGroupBy>()
            {
                new QueryRequestGroupBy()
                {
                    FieldId = 3, Grouping = "equal-values"
                }
            };

            var result = PostRequest <QueryRequestModel, QueryResponseModel>("/v1/records/query", queryRequest);

            var products = new List <ProductContract>();

            if (result.Data != null)
            {
                foreach (var data in result.Data)
                {
                    products.Add(new ProductContract(data));
                }
            }

            return(products);
        }
 public async Task <ActionResult <IEnumerable <GetFleetCustomerDriverList_ViewModel> > > Get(int customerId, [FromQuery] QueryRequestModel queryRequest)
 {
     return(Ok(await Mediator.Send(new GetFleetCustomerCardListQuery(customerId, queryRequest))));
 }
Beispiel #15
0
        public async Task <LoadResult> Drivers(DataSourceLoadOptions loadOptions, [FromQuery] QueryRequestModel queryRequestModel)
        {
            var response = DataSourceLoader.Load <GetCardShipmentAddressQueryable_Dto>(await Mediator.Send(new GetCardShipmentAddressQueryable_Query(queryRequestModel)), loadOptions);

            return(response);
        }
 public GetFleetCardQueryable_Query(QueryRequestModel queryRequestModel)
 {
     QueryRequestModel = queryRequestModel;
 }
Beispiel #17
0
 public GetFleetDriverListQuery(QueryRequestModel queryRequest)
 {
     QueryRequest = queryRequest;
 }
Beispiel #18
0
 public GetVehicleQueryable_Query(QueryRequestModel queryRequestModel, IMapper mapper)
 {
     mapper.Map(queryRequestModel, this);
 }
Beispiel #19
0
 public GetSampleQueryable_Query(QueryRequestModel queryRequestModel)
 {
     QueryRequestModel = queryRequestModel;
 }
Beispiel #20
0
 public GetFleetCardListQuery(QueryRequestModel queryRequest)
 {
     QueryRequest = queryRequest;
 }
Beispiel #21
0
 public async Task <ActionResult <GetFleetOrgLevelDefinitionList_ViewModel> > GetAll([FromQuery] QueryRequestModel queryRequest)
 {
     return(Ok(await Mediator.Send(new GetFleetOrgLevelDefinitionList_Query(queryRequest))));
 }
Beispiel #22
0
 public GetLocationQueryable_Query(QueryRequestModel queryRequestModel)
 {
     QueryRequestModel = queryRequestModel;
 }
Beispiel #23
0
 public GetOrgLevelDefinitionsQueryable_Query(QueryRequestModel queryRequestModel, IMapper mapper)
 {
     mapper.Map(queryRequestModel, this);
 }
Beispiel #24
0
 public GetCustomerCardCategoryQueryable_Query(QueryRequestModel queryRequestModel)
 {
     QueryRequestModel = queryRequestModel;
 }
Beispiel #25
0
 public GetFleetCustomerCardListQuery(int customerId, QueryRequestModel queryRequest)
 {
     QueryRequest = queryRequest;
     CustomerId   = customerId;
 }
Beispiel #26
0
 public GetFleetOrgLevelDefinitionList_Query(QueryRequestModel queryRequest)
 {
     QueryRequest = queryRequest;
 }
 public EntityListQuery(QueryRequestModel queryRequest)
 {
     QueryRequest = queryRequest;
 }
Beispiel #28
0
 public GetTransactionsQueryable_Query(QueryRequestModel queryRequestModel, IMapper mapper)
 {
     mapper.Map(queryRequestModel, this);
 }
Beispiel #29
0
 public GetBusinessHoursQueryable_Query(QueryRequestModel queryRequestModel)
 {
     QueryRequestModel = queryRequestModel;
 }
Beispiel #30
0
        public async Task <LoadResult> Customers(DataSourceLoadOptions loadOptions, [FromQuery] QueryRequestModel queryRequestModel)
        {
            var response = DataSourceLoader.Load(await Mediator.Send(new GetCustomerQueryable_Query(queryRequestModel, _mapper)), loadOptions);

            return(response);
        }