// 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)); }
/// <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); }
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); }