예제 #1
0
        public async Task <IEnumerable <SpecificationModel> > GetProdSpecificationsAsync(Entities.Products product)
        {
            var prodSpec = _mapper.Map <ProductSpecificationModel>(product);

            prodSpec = _mapper.Map(product.ProductVariants.FirstOrDefault(), prodSpec);

            var listOfAttributes = _mapper.Map <ExpandoObject>(prodSpec);
            var specifications   = await _unit.ProductSpecificationRepository.GetListAsync();

            var resultModel = listOfAttributes.Where(attribute => attribute.Value != null).Join(specifications, attribute => attribute.Key, spec => spec.NormalizedName,
                                                                                                (attribute, spec) => new SpecificationModel
            {
                Name        = spec.Name,
                Value       = attribute.Value,
                Description = spec.Description
            });

            return(resultModel);
        }
예제 #2
0
 public Entities.Products AddProduct(Entities.Products product)
 {
     DAL.Products products = new DAL.Products();
     products.AddProduct(product);
     return(product);
 }