コード例 #1
0
        public HttpResponseMessage QuoteRequestMarketPlaceSearch([FromUri] MarketPlaceRequest model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (model.CategoryIds != null && model.CategoryIds.Count > 0)
            {
                DataTable CategoryIds = new DataTable(); //<---
                CategoryIds.Clear();                     //<---

                // Create column.
                var column = new DataColumn();
                column.DataType      = System.Type.GetType("System.Int32");
                column.ColumnName    = "CategoryId";
                column.AutoIncrement = false;
                column.Caption       = "CategoryId";
                column.ReadOnly      = false;
                column.Unique        = false;
                // Add the column to the table.
                CategoryIds.Columns.Add(column); //<---

                //CategoryIds.Columns.Add("CategoryId");

                foreach (int CategoryId in model.CategoryIds)
                {
                    //- Populate the DataTable for the loading the schedules
                    DataRow _category = CategoryIds.NewRow(); //<---
                    _category["CategoryId"] = CategoryId;     //<---
                    if (_category["CategoryId"] != null)
                    {
                    }
                    CategoryIds.Rows.Add(_category); //<---
                    if (CategoryIds.Rows[0].ItemArray[0] != null)
                    {
                        var thing = CategoryIds.Rows[0].ItemArray[0];
                    }
                }
                ;

                model.CategoryIdList = CategoryIds;
            }

            var marketPlaceQuoteRequest = new List <MarketPlaceDomain>();

            // handling multiple catergories is a little buggy.
            // Do just one if possible.
            marketPlaceQuoteRequest = _MarketPlaceService.GetByQuoteRequestId(model);

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

            response.Items = marketPlaceQuoteRequest;

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
コード例 #2
0
        public List <MarketPlaceDomain> GetBySingleQuoteRequestId(MarketPlaceRequest model)
        {
            List <MarketPlaceDomain> marketplaceQR = null;
            int category = model.CategoryIds[0] / 100;

            try
            {
                DataProvider.ExecuteCmd(GetConnection, "dbo.QuoteRequests_GetBySingleCategorySearchRadius"
                                        , inputParamMapper : delegate(SqlParameterCollection paramCollection)
                {
                    paramCollection.AddWithValue("@categoryid", category);
                    paramCollection.AddWithValue("@latpoint", model.LatPoint);
                    paramCollection.AddWithValue("@lngpoint", model.LngPoint);
                    paramCollection.AddWithValue("@radius", model.Radius);
                }, map : delegate(IDataReader reader, short set)
                {
                    MarketPlaceDomain items = new MarketPlaceDomain();
                    int startingIndex       = 0; //startingOrdinal

                    items.QuoteRequestId = reader.GetSafeInt32(startingIndex++);
                    items.AddressId      = reader.GetSafeInt32(startingIndex++);
                    items.CompanyId      = reader.GetSafeInt32(startingIndex++);
                    items.Name           = reader.GetSafeString(startingIndex++);
                    items.Estimation     = reader.GetSafeString(startingIndex++);
                    items.DueDate        = reader.GetSafeDateTime(startingIndex++);
                    items.CategoryId     = reader.GetSafeInt32(startingIndex++);
                    items.Details        = reader.GetSafeString(startingIndex++);
                    items.Address1       = reader.GetSafeString(startingIndex++);
                    items.City           = reader.GetSafeString(startingIndex++);
                    items.State          = reader.GetSafeString(startingIndex++);
                    items.ZipCode        = reader.GetSafeString(startingIndex++);
                    items.StatusId       = (QRState)reader.GetSafeInt32(startingIndex++);
                    items.LatPoint       = reader.GetSafeDecimal(startingIndex++);
                    items.LngPoint       = reader.GetSafeDecimal(startingIndex++);
                    items.Distance       = reader.GetSafeDouble(startingIndex++);
                    items.Status         = items.StatusId.ToString();

                    if (marketplaceQR == null)
                    {
                        marketplaceQR = new List <MarketPlaceDomain>();
                    }

                    marketplaceQR.Add(items);
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(marketplaceQR);
        }