private static JurisdictionGroup InitializeItem(JurisdictionGroup item, IEnumerable <ImportItem> systemValues) { if (item == null) { item = new OrderEntityFactory().CreateEntity <JurisdictionGroup>(); } var itemProperties = item.GetType().GetProperties(); systemValues.ToList().ForEach(x => SetPropertyValue(item, itemProperties.FirstOrDefault(y => y.Name == x.Name), x.Value)); return(item); }
/// <summary> /// 获取权限组 /// </summary> /// <returns></returns> public static void GetJurGroups(out List <JurisdictionGroup> list) { list = new List <JurisdictionGroup>(); string sql = "select GroupID,GroupName,Description,DefaultGroup from ipvt_jurgrouptable"; MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sql); while (reader.Read()) { var group = new JurisdictionGroup(); group.GroupId = EvaluationHelper.ObjectToInt(reader["GroupID"]); group.Default = EvaluationHelper.ObjectToInt(reader["DefaultGroup"]); group.GroupName = reader["GroupName"].ToString(); group.Description = reader["Description"].ToString(); list.Add(group); } } catch (Exception ex) { LogHelper.MainLog("error in JurisdictionManager.GetJurGroups()!" + ex.Message); } finally { if (reader != null) { reader.Close(); //读取完关闭reader对象 } } foreach (JurisdictionGroup group in list) { List <Jurisdiction> js; GetJurisdictions(group.GroupId, out js); if (js != null) { foreach (Jurisdiction jur in js) { group.Jurisdictions.Add(jur); } } } }
/// <summary> /// 更新权限组 /// </summary> /// <param name="group"></param> /// <returns></returns> public static bool UpdateGroup(JurisdictionGroup group) { var models = new List <SqlTextModel>(); if (group != null && group.GroupId > 0 && !string.IsNullOrEmpty(group.GroupName)) { //更新权限组表组信息 string gsql = "update ipvt_jurgrouptable set GroupName=?name,Description=?des where GroupID=?id"; var ps = new MySqlParameter[3]; ps[0] = new MySqlParameter("?name", group.GroupName); ps[1] = new MySqlParameter("?des", group.Description); ps[2] = new MySqlParameter("?id", group.GroupId); models.Add(new SqlTextModel { SqlString = gsql, MySqlParams = ps }); //删除权限组-权限表指定组的旧对应数据 string delsql = "delete from ipvt_jurisdiction_grouptable where GroupID=?id"; var delps = new[] { new MySqlParameter("?id", group.GroupId) }; models.Add(new SqlTextModel { SqlString = delsql, MySqlParams = delps }); //添加权限组-权限表指定组的新对应数据 foreach (Jurisdiction jur in group.Jurisdictions) { string insertsql = "insert into ipvt_jurisdiction_grouptable(GroupID,JurisdictionID) values(?gid,?jid)"; var inps = new MySqlParameter[2]; inps[0] = new MySqlParameter("?gid", group.GroupId); inps[1] = new MySqlParameter("?jid", jur.Id); models.Add(new SqlTextModel { SqlString = insertsql, MySqlParams = inps }); } return(CustomMySqlHelper.ExecuteSqlList(models));//事务批量执行 } return(false); }
/// <summary> /// 插入权限组 /// </summary> /// <param name="group"></param> /// <returns></returns> public static bool InsertGroup(JurisdictionGroup group) { var models = new List <SqlTextModel>(); if (group != null && !string.IsNullOrEmpty(group.GroupName)) { //插入组信息 string gsql = "insert into ipvt_jurgrouptable(GroupName,Description) values(?name,?des);SELECT @@IDENTITY"; var ps = new MySqlParameter[2]; ps[0] = new MySqlParameter("?name", group.GroupName); ps[1] = new MySqlParameter("?des", group.Description); int newid = EvaluationHelper.ObjectToInt(CustomMySqlHelper.ExecuteScalar(gsql, ps)); if (newid > 0) { //添加权限组-权限表指定组的新对应数据 foreach (Jurisdiction jur in group.Jurisdictions) { string insertsql = "insert into ipvt_jurisdiction_grouptable(GroupID,JurisdictionID) values(?gid,?jid)"; var inps = new MySqlParameter[2]; inps[0] = new MySqlParameter("?gid", newid); inps[1] = new MySqlParameter("?jid", jur.Id); models.Add(new SqlTextModel { SqlString = insertsql, MySqlParams = inps }); } return(CustomMySqlHelper.ExecuteSqlList(models));//事务批量执行 } } return(false); }
public void Can_run_activity_calculatetaxtotals() { var orderGroup = CreateOrderConstant(); var catrepository = new Mock <ICatalogRepository>(); var items = new List <Item>(); orderGroup.OrderForms[0].Shipments[0].ShipmentItems.ToList().ForEach(item => items.Add(new Product { ItemId = item.LineItem.CatalogItemId, TaxCategory = "472b9809-3530-4d95-9886-cbddcaa0b72e" })); orderGroup.OrderForms[0].Shipments[0].ShippingCost = 10; catrepository.Setup(x => x.Items).Returns(() => items.ToArray().AsQueryable()); catrepository.SetupAllProperties(); var taxrepository = new Mock <ITaxRepository>(); var taxes = new[] { new Tax { Name = "US Shipment tax", TaxType = (int)TaxTypes.ShippingTax, SortOrder = 1 }, new Tax { Name = "US Sales tax", TaxType = (int)TaxTypes.SalesTax, SortOrder = 1 } }; var jurisdiction = new Jurisdiction { Code = "VAT", CountryCode = "USA", JurisdictionType = (int)JurisdictionTypes.All }; var jurisdictionGroup = new JurisdictionGroup { DisplayName = "USA VAT", Code = "USAVAT", JurisdictionType = (int)JurisdictionTypes.All }; var jurisdictionRel = new JurisdictionRelation { JurisdictionGroup = jurisdictionGroup, JurisdictionGroupId = jurisdictionGroup.JurisdictionGroupId, Jurisdiction = jurisdiction, JurisdictionId = jurisdiction.JurisdictionId }; jurisdictionGroup.JurisdictionRelations.Add(jurisdictionRel); taxes[0].TaxValues.Add(new TaxValue() { AffectiveDate = new DateTime(2013, 6, 1), Percentage = 18, TaxCategory = "472b9809-3530-4d95-9886-cbddcaa0b72e", TaxId = taxes[0].TaxId, Tax = taxes[0], JurisdictionGroup = jurisdictionGroup, JurisdictionGroupId = jurisdictionGroup.JurisdictionGroupId }); taxes[1].TaxValues.Add(new TaxValue() { AffectiveDate = new DateTime(2013, 6, 1), Percentage = 5, TaxCategory = "472b9809-3530-4d95-9886-cbddcaa0b72e", TaxId = taxes[1].TaxId, Tax = taxes[1], JurisdictionGroup = jurisdictionGroup, JurisdictionGroupId = jurisdictionGroup.JurisdictionGroupId }); taxrepository.Setup(x => x.Taxes).Returns(taxes.AsQueryable); taxrepository.SetupAllProperties(); var activity = new CalculateTaxActivity(catrepository.Object, taxrepository.Object, CacheRepository); var result = InvokeActivity(activity, orderGroup); var order = result.OrderGroup; // now check totals // Order totals Assert.Equal(order.TaxTotal, 660.24M); Assert.Equal(order.OrderForms[0].Shipments[0].ItemTaxTotal, 609.84M); Assert.Equal(order.OrderForms[0].Shipments[0].ShippingTaxTotal, 12.6M); }
public JurisdictionGroupOverviewStepViewModel(IRepositoryFactory <IOrderRepository> repositoryFactory, IOrderEntityFactory entityFactory, JurisdictionTypes jurisdictionType, JurisdictionGroup item) : base(repositoryFactory, entityFactory, jurisdictionType, item) { }
public CreateJurisdictionGroupViewModel(IViewModelsFactory <IJurisdictionGroupOverviewStepViewModel> vmFactory, JurisdictionTypes jurisdictionType, JurisdictionGroup item) { RegisterStep(vmFactory.GetViewModelInstance( new KeyValuePair <string, object>("item", item) , new KeyValuePair <string, object>("jurisdictionType", jurisdictionType))); }