public HttpResponseMessage Get(SkumetaData skumetaData)
        {
            try
            {
                log.Error($"Sku Meta Data get Execution Started" + DateTime.Now);
                var skuobject = _unitOfWork.SubCategoryRepository
                                .GetSKUmetaData(skumetaData)
                                .AsEnumerable().Select((data, index) => new SkumetaData()
                {
                    SKUID       = "SKU" + index,
                    Location    = data.Location,
                    Category    = data.Category,
                    Department  = data.Department,
                    SubCategory = data.SubCategory
                }).ToList();


                return(Request.CreateResponse(HttpStatusCode.OK, skuobject));
            }
            catch (Exception ex)
            {
                log.Error($"Sku Meta Data get  Execution error" + ex);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Error Occured while Getting record"));
            }
        }
Пример #2
0
        public void SkuMetaDataGetTest()
        {
            //api / v1 / location /{ location_id}/ department /
            SkumetaData sub = new SkumetaData();

            _httpResponseMessage = _locationController.Get(sub);
            var actul    = _httpResponseMessage.IsSuccessStatusCode;
            var expected = true;

            Assert.AreEqual(expected, actul);
            Assert.AreEqual(HttpStatusCode.OK, _httpResponseMessage.StatusCode);
        }
        public IQueryable <SkumetaData> GetSKUmetaData(SkumetaData skumetaData)
        {
            var data = from loc in HierarichyContext.Locations.Where(c => c.Description == skumetaData.Location)
                       join dept in HierarichyContext.Departments.Where(c => c.Description == skumetaData.Department) on loc.Location_Id equals dept.Location_ID
                       join cat in HierarichyContext.Categories.Where(c => c.Description == skumetaData.Category) on dept.Department_Id equals cat.Department_ID
                       join subcat in HierarichyContext.SubCategories.Where(c => c.Description == skumetaData.SubCategory) on cat.Category_Id equals subcat.Category_Id
                       select new SkumetaData()
            {
                Location    = loc.Description,
                Department  = dept.Description,
                Category    = cat.Description,
                SubCategory = subcat.Description
            };


            return(data);
        }