public virtual ActionResult Delete(ProductPropertyModel model) { _ProductPropertyService.DeleteProductProperty(model.Id); var sd = _uow.SaveChanges(); return(null); }
//method to return all properties of product which are defined in the templates. public ResultModel <List <ProductPropertyModel> > GetProductProperties(int productId, int templateId) { var methodResult = new ResultModel <List <ProductPropertyModel> >(); var properties = unitOfWork.TemplatePropertyRepository.GetAll(x => x.TemplateId == templateId && x.IsDeleted != true); var productProperties = unitOfWork.ProductPropertyRepository.GetAll(x => x.ProductId == productId); var propertiesModel = new List <ProductPropertyModel>(); foreach (var prop in properties) { var productProp = productProperties.SingleOrDefault(x => x.TemplatePropertyId == prop.TemplatePropertyId); string propValue = string.Empty; if (productProp != null) { propValue = productProp.PropertyValue; } var propModel = new ProductPropertyModel { PropertyValue = propValue, TemplatePropertyId = prop.TemplatePropertyId, PropertyName = prop.PropertyName, DataType = prop.DataType, ProductId = productId, IsRequired = prop.IsRequired }; propertiesModel.Add(propModel); } methodResult.Data = propertiesModel; return(methodResult); }
public virtual ActionResult Create(ProductPropertyModel model) { _ProductPropertyService.AddProductProperty(model); var sd = _uow.SaveChanges(); return(null); }
public void AddProductProperty(ProductPropertyModel ProductPropertyModel) { Mapper.Initialize(cfg => cfg.CreateMap <ProductPropertyModel, ProductProperty>()); var ProductPropertyItem = Mapper.Map <ProductProperty>(ProductPropertyModel); _ProductProperty.Add(ProductPropertyItem); }
public IActionResult Detail(string categoryCode, string subCategoryCode, string productType, string productId) { DetailViewModel detailViewModel = new DetailViewModel(); List <Categories> categories = _categoriesBusinessService.GetAllWithSubCategories(); Product product = _productBusinessService.GetByIdWithDetails(Convert.ToInt32(productId)); List <ProductTypes> productTypes = _productTypesBusinessService.GetAllBySubCategory(subCategoryCode); detailViewModel.Categories = categories.Select(x => new CategoryModel { Id = x.Id, Description = x.Description, Image = x.Image, Name = x.Name, Code = x.Code, SubCategories = x.SubCategories.Select(y => new SubCategoryModel { Description = y.Description, Name = y.Name, Code = y.Code, CategoryCode = y.Category.Code }).ToList() }).ToList(); detailViewModel.Product = new ProductModel { Brand = product.BrandModel.Brand.Name, Currency = product.Currency, Image = product.Image, Model = product.BrandModel.Name, Price = product.Price, ProductCode = product.ProductCode, Id = product.Id, CategoryCode = product.BrandModel.ProductType.SubCategory.Category.Code, SubCategoryCode = product.BrandModel.ProductType.SubCategory.Code, ProductTypeCode = product.BrandModel.ProductType.Code, }; detailViewModel.Product.ProductProperties = new List <ProductPropertyModel>(); foreach (ProductPropertyValues item in product.BrandModel.ProductPropertyValues) { ProductPropertyModel productProperty = new ProductPropertyModel(); productProperty.Property = item.ProductProperty.Property; productProperty.Value = item.Value; detailViewModel.Product.ProductProperties.Add(productProperty); } detailViewModel.Product.Comments = product.Comments.Select(x => new ProductCommentModel { Comment = x.CommentText, CommentedBy = x.Customer.Name, CommentedDate = x.CommentDate }).ToList(); detailViewModel.ProductTypes = productTypes.Select(x => new ProductTypeModel { Code = x.Code, Name = x.Name, CategoryCode = x.SubCategory.Category.Code, SubCategoryCode = x.SubCategory.Code }).ToList(); return(View(detailViewModel)); }