Exemplo n.º 1
0
        public HttpResponseMessage GetByCategoryIdAndRadiusAndDesignation([FromUri] ProductByCategoryRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            ItemsResponse <SupplierDomain> response = new ItemsResponse <SupplierDomain>();

            response.Items = _CompanyService.GetByCategoryIdAndRadiusAndDesignation(model);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemplo n.º 2
0
        public async Task <List <ProductModel> > GetProductsByCategoryId(string categoryId, int pageIndex, int pageSize = GlobalSettings.AppConst.PageSize)
        {
            var builder = new UriBuilder(GlobalSettings.WooCommerceProductByCategoryEndpoint);
            var request = new ProductByCategoryRequest()
            {
                Category = categoryId,
                Page     = pageIndex,
                PageSize = pageSize
            };
            var queryParams = request.GetQueryString();

            builder.Query = queryParams;
            var uri = builder.ToString();

            return(await _requestService.GetAsync <List <ProductModel> >(uri));
        }
Exemplo n.º 3
0
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        public List <SupplierDomain> GetByCategoryIdAndRadiusAndDesignation(ProductByCategoryRequest model)
        {
            List <SupplierDomain> companyList = null;

            try
            {
                DataProvider.ExecuteCmd(GetConnection, "dbo.Suppliers_GetByCategoryIdAndRadiusAndDesignation"
                                        , inputParamMapper : delegate(SqlParameterCollection paramCollection)
                {
                    paramCollection.AddWithValue("@CategoryId", model.CategoryId);
                    paramCollection.AddWithValue("@latpoint", model.Latitude);
                    paramCollection.AddWithValue("@lngpoint", model.Longitude);
                    paramCollection.AddWithValue("@radius", model.Radius);
                    paramCollection.AddWithValue("@designations", model.Designations);
                }
                                        , map : delegate(IDataReader reader, short set)
                {
                    SupplierDomain singleCompany = new SupplierDomain();

                    int startingIndex = 0;  //startingOrdinal

                    singleCompany.CompanyName        = reader.GetSafeString(startingIndex++);
                    singleCompany.Designations       = reader.GetSafeInt32(startingIndex++);
                    singleCompany.URL                = reader.GetSafeString(startingIndex++);
                    singleCompany.Email              = reader.GetSafeString(startingIndex++);
                    singleCompany.MediaUrl           = reader.GetSafeString(startingIndex++);
                    singleCompany.Phone              = reader.GetSafeString(startingIndex++);
                    singleCompany.CompanyId          = reader.GetSafeInt32(startingIndex++);
                    singleCompany.ProductName        = reader.GetSafeString(startingIndex++);
                    singleCompany.Category           = reader.GetSafeString(startingIndex++);
                    singleCompany.ProductDescription = reader.GetSafeString(startingIndex++);
                    singleCompany.Cost               = reader.GetSafeDecimal(startingIndex++);
                    singleCompany.Quantity           = reader.GetSafeInt32(startingIndex++);
                    singleCompany.Threshold          = reader.GetSafeInt32(startingIndex++);
                    singleCompany.MinPurchase        = reader.GetSafeInt32(startingIndex++);
                    singleCompany.ProductMediaId     = reader.GetSafeInt32(startingIndex++);
                    singleCompany.CategoryId         = reader.GetSafeInt32(startingIndex++);
                    singleCompany.Latitude           = reader.GetSafeDecimal(startingIndex++);
                    singleCompany.Longitude          = reader.GetSafeDecimal(startingIndex++);
                    singleCompany.Address1           = reader.GetSafeString(startingIndex++);
                    singleCompany.City               = reader.GetSafeString(startingIndex++);
                    singleCompany.State              = reader.GetSafeString(startingIndex++);
                    singleCompany.ZipCode            = reader.GetSafeString(startingIndex++);
                    singleCompany.distance_in_mi     = (decimal)reader.GetSafeDouble(startingIndex++);


                    if (companyList == null)
                    {
                        companyList = new List <SupplierDomain>();
                    }

                    companyList.Add(singleCompany);
                }
                                        );
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(companyList);
        }