public void SetUp() { base.SetUp(); shipmentApplicationService = ApplicationContext.Current["shipmentApplicationService"] as IShipmentApplicationService; productApplicationService = ApplicationContext.Current["productApplicationService"] as IProductApplicationService; attributeSetInstanceApplicationService = ApplicationContext.Current["attributeSetInstanceApplicationService"] as IAttributeSetInstanceApplicationService; }
public static IEnumerable <IAttributeSetInstanceState> GetByProperty <TPropertyType>(this IAttributeSetInstanceApplicationService applicationService, System.Linq.Expressions.Expression <Func <IAttributeSetInstanceState, TPropertyType> > propertySelector, TPropertyType propertyValue, IList <string> orders = null, int firstResult = 0, int maxResults = int.MaxValue) { return(applicationService.GetByProperty(ReflectUtils.GetPropertyName <IAttributeSetInstanceState, TPropertyType>(propertySelector), propertyValue, orders, firstResult, maxResults)); }
//static readonly ILog _log = LogManager.GetLogger<AttributeSetInstanceUtils>(); public static string CreateAttributeSetInstance(IAttributeSetService attributeSetService, IAttributeSetInstanceApplicationService attrSetInstApplicationService, string attrSetId, IDictionary <string, object> attrSetInstDict) { IDictionary <string, string> nameDict = null; if (String.IsNullOrWhiteSpace(attrSetId)) { nameDict = new Dictionary <string, string>(); } else { nameDict = attributeSetService.GetPropertyExtensionFieldDictionary(attrSetId); } var createAttrSetInst = new CreateAttributeSetInstance(); createAttrSetInst.AttributeSetId = (attrSetId == null ? "*" : attrSetId); foreach (var kv in attrSetInstDict) { // ////////////////////////////////////////// var fname = nameDict.ContainsKey(kv.Key) ? nameDict[kv.Key] : kv.Key; // createAttrSetInst.AirDryMetricTon = (decimal)kv.Value; var b = ReflectUtils.TrySetPropertyValue(fname, createAttrSetInst, kv.Value); if (!b) { var fmt = "Set property error. Property name: {0}"; //if (_log.IsInfoEnabled) { _log.Info(String.Format(fmt, fname)); } throw new DomainError(fmt, fname); } // ////////////////////////////////////////// } var attrSetInstId = attrSetInstApplicationService.CreateWithoutId(createAttrSetInst); return(attrSetInstId); }