/// <inheritdoc /> public override void LoadType(IGenericColumns source, IProductType target) { var watch = (WatchType)target; watch.Weight = source.Float1; watch.Price = source.Float2; }
//ended by Suranjana public MasterController(IDepartmentService DepartmentService, IDivisionService DivisionService, ILocalizationService localizationService, IExecutive ExecutiveService, IWorkContext workContext, IProductType ProductTypeService //added by Saddam on 17/05/2016 , IAuthorService AuthorService, //Added by sanjeet IPublishingCompanyService publishingCompanyService, IEncryptionService encryptionService, ICommonListService commonList, IDbContext dbContext, //Added By Ankush Kumar on 11/07/2016 ISubsidiaryRightsService subsidiaryRightsService, //Added by Suranjana on 11/07/2016 ITypeOfRightsService typeOfRightsService ) { _DepartmentService = DepartmentService; _DivisionService = DivisionService; _localizationService = localizationService; _ExecutiveService = ExecutiveService; _workContext = workContext; _ProductTypeService = ProductTypeService; //Added by saddam on 17/05/2016 _AuthorTypeService = AuthorService; //ended by saddam _publishingCompanyService = publishingCompanyService; _encryptionService = encryptionService; _commonList = commonList; this._dbContext = dbContext; //Added by Suranjana on 11/07/2016 _typeOfRightsService = typeOfRightsService; }
/// <inheritdoc /> public override bool HasChanged(IProductType current, IGenericColumns dbProperties) { var watch = (WatchType)current; return(Math.Abs(watch.Weight - dbProperties.Float1) > 0.01 || Math.Abs(watch.Price - dbProperties.Float2) > 0.01); }
/// <inheritdoc /> public override void SaveType(IProductType source, IGenericColumns target) { var watch = (WatchType)source; target.Float1 = watch.Weight; target.Float2 = watch.Price; }
public IProductRecipe ConvertRecipeBack(RecipeModel recipe, IProductType productType) { IProductRecipe productRecipe; if (recipe.Id == 0) { var type = ReflectionTool.GetPublicClasses <IProductRecipe>(t => t.Name == recipe.Type).First(); productRecipe = (IProductRecipe)Activator.CreateInstance(type); } else { productRecipe = RecipeManagement.Get(recipe.Id); } productRecipe.Name = recipe.Name; productRecipe.Revision = recipe.Revision; productRecipe.State = recipe.State; // Only load workplan if it changed var workplanRecipe = productRecipe as IWorkplanRecipe; if (workplanRecipe != null && workplanRecipe.Workplan?.Id != recipe.WorkplanId) { workplanRecipe.Workplan = WorkplanManagement.LoadWorkplan(recipe.WorkplanId); } if (productRecipe.Product == null) { productRecipe.Product = productType; } switch (recipe.Classification) { case RecipeClassificationModel.Unset: productRecipe.Classification = RecipeClassification.Unset; break; case RecipeClassificationModel.Default: productRecipe.Classification = RecipeClassification.Default; break; case RecipeClassificationModel.Alternative: productRecipe.Classification = RecipeClassification.Alternative; break; case RecipeClassificationModel.Intermediate: productRecipe.Classification = RecipeClassification.Intermediate; break; case RecipeClassificationModel.Part: productRecipe.Classification = RecipeClassification.Part; break; default: throw new ArgumentOutOfRangeException(); } EntryConvert.UpdateInstance(productRecipe, recipe.Properties, RecipeSerialization); return(productRecipe); }
public long SaveType(IProductType modifiedInstance) { var saved = Storage.SaveType(modifiedInstance); RaiseProductChanged(modifiedInstance); return(saved); }
public IReadOnlyList <IProductRecipe> GetRecipes(IProductType productType, RecipeClassification classification) { ValidateHealthState(); var recipes = RecipeManagement.GetRecipes(productType, classification); return(recipes.Select(ReplaceOrigin).ToArray()); }
private static ProductFile[] ConvertFiles(IProductType productType, IEnumerable <PropertyInfo> properties) { var files = (from property in properties where property.PropertyType == typeof(ProductFile) select(ProductFile) property.GetValue(productType)).ToArray(); return(files); }
// method to get countries public static ProductType[] List(string apiUrl, string sessionId) { IProductType proxy = (IProductType)XmlRpcProxyGen.Create(typeof(IProductType)); proxy.Url = apiUrl; return(proxy.List(sessionId, _catalog_product_type_list)); }
public ProductInstance CreateInstance(IProductType productType, bool save) { var instance = productType.CreateInstance(); if (save) { SaveInstances(instance); } return(instance); }
public Product(string name, IProductType productType) : this() { if (productType == null) { throw new ArgumentNullException(nameof(productType)); } this.Name = name; this.Type = productType; }
public ProductTypeController(IProductType productTypeService, ILocalizationService localizationService, ILogger loggerService, IRepository <ProductTypeMaster> mobjProductTypeMaster, IRepository <ACS.Core.Domain.Product.ProductMaster> mobjProductMaster) { _productTypeService = productTypeService; _localizationService = localizationService; _loggerService = loggerService; _mobjProductTypeMaster = mobjProductTypeMaster; _mobjProductMaster = mobjProductMaster; }
/// <summary> /// Save a product to the database /// </summary> public long SaveType(IProductType modifiedInstance) { using (var uow = Factory.Create()) { var entity = SaveProduct(uow, modifiedInstance); uow.SaveChanges(); return(entity.Id); } }
/// <summary> /// Save a product to the database /// </summary> public long SaveType(IProductType modifiedInstance) { using (var uow = Factory.Create()) { var productSaverContext = new ProductPartsSaverContext(uow); var entity = SaveProduct(productSaverContext, modifiedInstance); uow.SaveChanges(); return(entity.Id); } }
public Category() { //初始化ASP.NET内置对象 Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); MyBLL = CategoryFactory.CreateCategory(); MyTBLL = ProductTypeFactory.CreateProductType(); }
public Brand() { //初始化ASP.NET内置对象 Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); brand = BrandFactory.CreateBrand(); MyProductType = ProductTypeFactory.CreateProductType(); }
private ProductModel ConvertProduct(IProductType productType, bool flat) { var converted = _productCache.FirstOrDefault(p => p.Id == productType.Id); if (converted != null) { return(converted); } // Base object var identity = (ProductIdentity)productType.Identity ?? EmptyIdentity; converted = new ProductModel { Id = productType.Id, Type = productType.GetType().Name, Name = productType.Name, State = productType.State, Identifier = identity.Identifier, Revision = identity.Revision }; if (flat) { return(converted); } // Properties var properties = productType.GetType().GetProperties(); converted.Properties = EntryConvert.EncodeObject(productType, ProductSerialization); // Files converted.Files = ConvertFiles(productType, properties); // Recipes var recipes = RecipeManagement.GetAllByProduct(productType); converted.Recipes = recipes.Select(ConvertRecipe).ToArray(); // Parts ConvertParts(productType, properties, converted); _productCache.Add(converted); return(converted); }
private ProductFileModel[] ConvertFiles(IProductType productType, IEnumerable <PropertyInfo> properties) { var productFileProperties = properties.Where(p => p.PropertyType == typeof(ProductFile)).ToArray(); var fileModels = new ProductFileModel[productFileProperties.Length]; for (int i = 0; i < fileModels.Length; i++) { var value = (ProductFile)productFileProperties[i].GetValue(productType); fileModels[i] = new ProductFileModel() { PropertyName = productFileProperties[i].Name, FileName = value?.Name, FileHash = value?.FileHash, FilePath = value?.FilePath, MimeType = value?.MimeType }; } return(fileModels); }
public SCMPurchasing() { //初始化ASP.NET内置对象 Response = System.Web.HttpContext.Current.Response; Request = System.Web.HttpContext.Current.Request; Server = System.Web.HttpContext.Current.Server; Session = System.Web.HttpContext.Current.Session; Application = System.Web.HttpContext.Current.Application; tools = ToolsFactory.CreateTools(); DBHelper = SQLHelperFactory.CreateSQLHelper(); depot = new SCMDepot(); supplier = new SCMSupplier(); PROBLL = ProductFactory.CreateProduct(); PROTYPEBLL = ProductTypeFactory.CreateProductType(); BRANDBLL = BrandFactory.CreateBrand(); }
public int CalcualteTotal() { // var type = typeof(IProductType); //var types = AppDomain.CurrentDomain.GetAssemblies() //.SelectMany(s => s.GetTypes()); int productPrice = 0; FactoryProduct factoryProduct = new FactoryProduct(); foreach (var key in ProductTypeWithQuantity.Keys) { IProductType product = factoryProduct.GetProduct(key); productPrice = ProductTypeWithQuantity[key] * product.productPrice; ProductTotalWithOutDiscount = ProductTotalWithOutDiscount + productPrice; } return(ProductTotalWithOutDiscount); }
private void ConvertParts(IProductType productType, IEnumerable <PropertyInfo> properties, ProductModel converted) { var connectors = new List <PartConnector>(); foreach (var property in properties) { var displayName = property.GetDisplayName(); if (typeof(IProductPartLink).IsAssignableFrom(property.PropertyType)) { var link = (IProductPartLink)property.GetValue(productType); var partModel = ConvertPart(link); var connector = new PartConnector { Name = property.Name, DisplayName = displayName, Type = FetchProductType(property.PropertyType), Parts = partModel is null ? new PartModel[0] : new[] { partModel }, PropertyTemplates = EntryConvert.EncodeClass(property.PropertyType, ProductSerialization) }; connectors.Add(connector); } else if (typeof(IEnumerable <IProductPartLink>).IsAssignableFrom(property.PropertyType)) { var links = (IEnumerable <IProductPartLink>)property.GetValue(productType); var linkType = property.PropertyType.GetGenericArguments()[0]; var connector = new PartConnector { IsCollection = true, Name = property.Name, DisplayName = displayName, Type = FetchProductType(linkType), Parts = links?.Select(ConvertPart).ToArray(), PropertyTemplates = EntryConvert.EncodeClass(linkType, ProductSerialization) }; connectors.Add(connector); } } converted.Parts = connectors.ToArray(); }
public ProductModel ConvertProduct(IProductType productType, bool flat) { // Base object var identity = (ProductIdentity)productType.Identity ?? EmptyIdentity; var converted = new ProductModel { Id = productType.Id, Type = productType.GetType().Name, Name = productType.Name, State = productType.State, Identifier = identity.Identifier, Revision = identity.Revision }; if (flat) { return(converted); } // Properties var properties = productType.GetType().GetProperties(); converted.Properties = EntryConvert.EncodeObject(productType, ProductSerialization); // Files converted.Files = (from property in properties where property.PropertyType == typeof(ProductFile) select(ProductFile) property.GetValue(productType)).ToArray(); converted.FileModels = ConvertFiles(productType, properties); // Recipes var recipes = RecipeManagement.GetAllByProduct(productType); converted.Recipes = recipes.Select(ConvertRecipe).ToArray(); // Parts ConvertParts(productType, properties, converted); return(converted); }
/// <summary> /// Load all parts of the product /// </summary> private void LoadParts(IUnitOfWork uow, ProductTypeEntity typeEntity, IProductType productType, IDictionary <long, IProductType> loadedProducts) { // Let's get nasty! // Load children var type = productType.GetType(); foreach (var part in LinkStrategies[type.Name].Values) { object value = null; var property = type.GetProperty(part.PropertyName); if (typeof(IProductPartLink).IsAssignableFrom(property.PropertyType)) { var linkEntity = FindLink(part.PropertyName, typeEntity); if (linkEntity != null) { var link = LinkConstructors[$"{type.Name}.{property.Name}"](); link.Id = linkEntity.Id; part.LoadPartLink(linkEntity, link); link.Product = (ProductType)Transform(uow, linkEntity.Child, true, loadedProducts, link); value = link; } } else if (typeof(IList).IsAssignableFrom(property.PropertyType)) { var linkEntities = FindLinks(part.PropertyName, typeEntity); var links = (IList)Activator.CreateInstance(property.PropertyType); foreach (var linkEntity in linkEntities) { var link = LinkConstructors[$"{type.Name}.{property.Name}"](); link.Id = linkEntity.Id; part.LoadPartLink(linkEntity, link); link.Product = (ProductType)Transform(uow, linkEntity.Child, true, loadedProducts, link); links.Add(link); } value = links; } property.SetValue(productType, value); } }
private ProductTypeEntity SaveProduct(IUnitOfWork uow, IProductType modifiedInstance) { var strategy = TypeStrategies[modifiedInstance.GetType().Name]; // Get or create entity var repo = uow.GetRepository <IProductTypeEntityRepository>(); var identity = (ProductIdentity)modifiedInstance.Identity; ProductTypeEntity typeEntity; var entities = repo.Linq .Where(p => p.Identifier == identity.Identifier && p.Revision == identity.Revision) .ToList(); // If entity does not exist or was deleted, create a new one if (entities.All(p => p.Deleted != null)) { typeEntity = repo.Create(identity.Identifier, identity.Revision, modifiedInstance.Name, modifiedInstance.GetType().Name); EntityIdListener.Listen(typeEntity, modifiedInstance); } else { typeEntity = entities.First(p => p.Deleted == null); typeEntity.Name = modifiedInstance.Name; // Set id in case it was imported under existing material and revision modifiedInstance.Id = typeEntity.Id; } // Check if we need to create a new version if (typeEntity.CurrentVersion == null || typeEntity.CurrentVersion.State != (int)modifiedInstance.State || strategy.HasChanged(modifiedInstance, typeEntity.CurrentVersion)) { var version = uow.GetRepository <IProductPropertiesRepository>().Create(); version.State = (int)modifiedInstance.State; typeEntity.SetCurrentVersion(version); } strategy.SaveType(modifiedInstance, typeEntity.CurrentVersion); // And nasty again! var type = modifiedInstance.GetType(); var linkRepo = uow.GetRepository <IPartLinkRepository>(); foreach (var linkStrategy in LinkStrategies[strategy.TargetType.Name].Values) { var property = type.GetProperty(linkStrategy.PropertyName); var value = property.GetValue(modifiedInstance); if (typeof(IProductPartLink).IsAssignableFrom(property.PropertyType)) { var link = (IProductPartLink)value; var linkEntity = FindLink(linkStrategy.PropertyName, typeEntity); if (linkEntity == null && link != null) // link is new { linkEntity = linkRepo.Create(linkStrategy.PropertyName); linkEntity.Parent = typeEntity; linkStrategy.SavePartLink(link, linkEntity); EntityIdListener.Listen(linkEntity, link); linkEntity.Child = GetPartEntity(uow, link); } else if (linkEntity != null && link == null) // link was removed { linkStrategy.DeletePartLink(new IGenericColumns[] { linkEntity }); linkRepo.Remove(linkEntity); } else if (linkEntity != null && link != null) // link was modified { linkStrategy.SavePartLink(link, linkEntity); linkEntity.Child = GetPartEntity(uow, link); } // else: link was null and is still null } else if (typeof(IEnumerable <IProductPartLink>).IsAssignableFrom(property.PropertyType)) { var links = (IEnumerable <IProductPartLink>)value; // Delete the removed ones var toDelete = (from link in typeEntity.Parts where link.PropertyName == linkStrategy.PropertyName where links.All(l => l.Id != link.Id) select link).ToArray(); linkStrategy.DeletePartLink(toDelete); linkRepo.RemoveRange(toDelete); // Save those currently active var currentEntities = FindLinks(linkStrategy.PropertyName, typeEntity).ToArray(); foreach (var link in links) { PartLink linkEntity; if (link.Id == 0 || (linkEntity = currentEntities.FirstOrDefault(p => p.Id == link.Id)) == null) { linkEntity = linkRepo.Create(linkStrategy.PropertyName); linkEntity.Parent = typeEntity; EntityIdListener.Listen(linkEntity, link); } else { linkEntity = typeEntity.Parts.First(p => p.Id == link.Id); } linkStrategy.SavePartLink(link, linkEntity); linkEntity.Child = GetPartEntity(uow, link); } } } return(typeEntity); }
public IReadOnlyList <IProductRecipe> GetRecipes(IProductType productType, RecipeClassification classification) { return(Storage.LoadRecipes(productType.Id, classification)); }
public IReadOnlyList <IProductRecipe> GetAllByProduct(IProductType productType) { return(Storage.LoadRecipes(productType.Id, RecipeClassification.CloneFilter)); }
private void RaiseProductChanged(IProductType productType) { // This must never by null // ReSharper disable once PossibleNullReferenceException TypeChanged(this, productType); }
public ProductTypesController(IProductType productType) { this._IProductType = productType; }
public ProductTypeController(IProductType repo, IMapper mapper) { _repo = repo; _mapper = mapper; }
public ProductInstance CreateInstance(IProductType productType, bool save) { ValidateHealthState(); return(ProductManager.CreateInstance(productType, save)); }