示例#1
0
        // GET: /Specification/List
        public IActionResult List()
        {
            var specificationEntities = _specificationService.GetAllSpecifications();
            var specificationList     = new List <SpecificationListModel>();

            foreach (var entity in specificationEntities)
            {
                // map entity to view model
                var specification = _mapper.Map <Specification, SpecificationListModel>(entity);
                specificationList.Add(specification);
            }

            return(View(specificationList));
        }
示例#2
0
        /// <summary>
        /// Get specification key select list
        /// </summary>
        /// <returns>Select list specification key</returns>
        public SelectList GetSpecificationKeySelectList()
        {
            var specifications    = _specificationService.GetAllSpecifications();
            var specificationList = new List <SpecificationKeySelectList>();

            foreach (var specification in specifications)
            {
                var specificationModel = new SpecificationKeySelectList
                {
                    Text  = specification.Name,
                    Value = specification.Id.ToString()
                };

                specificationList.Add(specificationModel);
            }

            var selectList = new SelectList(specificationList.OrderBy(x => x.Text), "Value", "Text");

            return(selectList);
        }
示例#3
0
        public bool CheckForDuplicate(ServiceType serviceType, DataType dataType, string value)
        {
            if (value == "")
            {
                return(true);
            }

            var entities = new List <string>();

            if (dataType == DataType.Name)
            {
                if (serviceType == ServiceType.Category)
                {
                    entities = _categoryService.GetAllCategories()
                               .Select(x => x.Name.ToLower())
                               .ToList();
                }
                else if (serviceType == ServiceType.Manufacturer)
                {
                    entities = _manufacturerService.GetAllManufacturers()
                               .Select(x => x.Name.ToLower())
                               .ToList();
                }
                else if (serviceType == ServiceType.Product)
                {
                    entities = _productService.GetAllProducts()
                               .Select(x => x.Name.ToLower())
                               .ToList();
                }
                else if (serviceType == ServiceType.Specification)
                {
                    entities = _specificationService.GetAllSpecifications()
                               .Select(x => x.Name.ToLower())
                               .ToList();
                }
            }
            else if (dataType == DataType.Seo)
            {
                if (serviceType == ServiceType.Category)
                {
                    entities = _categoryService.GetAllCategories()
                               .Select(x => x.SeoUrl.ToLower())
                               .ToList();
                }
                else if (serviceType == ServiceType.Manufacturer)
                {
                    entities = _manufacturerService.GetAllManufacturers()
                               .Select(x => x.SeoUrl.ToLower())
                               .ToList();
                }
                else if (serviceType == ServiceType.Product)
                {
                    entities = _productService.GetAllProducts()
                               .Select(x => x.SeoUrl.ToLower())
                               .ToList();
                }
            }

            // check for duplicate
            if (!entities.Contains(value.ToLower()))
            {
                return(false);
            }

            // value exist
            return(true);
        }