///<summary> /// Update the Typed ShipMethod Entity with modified mock values. ///</summary> static public void UpdateMockInstance_Generated(TransactionManager tm, ShipMethod mock) { mock.Name = TestUtility.Instance.RandomString(24, false);; mock.ShipBase = TestUtility.Instance.RandomShort(); mock.ShipRate = TestUtility.Instance.RandomShort(); mock.ModifiedDate = TestUtility.Instance.RandomDateTime(); }
public IShipMethod BuildEntity(ShipMethodDto dto) { var deserialized = JsonConvert.DeserializeObject <ProvinceCollection <ShipProvince> >(dto.ProvinceData); // TODO : fix this mapping var provinces = new ProvinceCollection <IShipProvince>(); foreach (var p in deserialized) { provinces.Add(p); } var shipMethod = new ShipMethod(dto.ProviderKey, dto.ShipCountryKey) { Key = dto.Key, Name = dto.Name, Surcharge = dto.Surcharge, ServiceCode = dto.ServiceCode, Taxable = dto.Taxable, Provinces = provinces, UpdateDate = dto.UpdateDate, CreateDate = dto.CreateDate }; shipMethod.ResetDirtyProperties(); return(shipMethod); }
private decimal GetFlatShipRate(ShipMethod shipMethod) { decimal rate = 0; if (shipMethod.ShipRateMatrices.Count > 0) { rate = shipMethod.ShipRateMatrices[0].Rate; } Basket basket = AbleContext.Current.User.Basket; //ADD ADDITIONAL SURCHARGE DEFINED FOR THIS SHIP METHOD decimal surchargeAmount; if (shipMethod.SurchargeModeId == (byte)SurchargeMode.PercentofShippingCharge) { surchargeAmount = Math.Round(((Decimal)rate / 100) * (Decimal)shipMethod.Surcharge, 2); } else if (shipMethod.SurchargeModeId == (byte)SurchargeMode.PercentofShippingTotal) { surchargeAmount = Math.Round((basket.Items.TotalPrice() / 100) * (Decimal)shipMethod.Surcharge, 2); } else { surchargeAmount = shipMethod.Surcharge; } rate += surchargeAmount; return(rate); }
protected void Page_Init(object sender, System.EventArgs e) { _ShipMethodId = AlwaysConvert.ToInt(Request.QueryString["ShipMethodId"]); _ShipMethod = ShipMethodDataSource.Load(_ShipMethodId); if (_ShipMethod == null) { RedirectMe(); } //BIND TAX CODES IList <TaxCode> taxCodes = AbleContext.Current.Store.TaxCodes; TaxCode.DataSource = taxCodes; TaxCode.DataBind(); ListItem item = TaxCode.Items.FindByValue(_ShipMethod.TaxCodeId.ToString()); if (item != null) { TaxCode.SelectedIndex = TaxCode.Items.IndexOf(item); } SurchargeTaxCode.DataSource = taxCodes; SurchargeTaxCode.DataBind(); item = SurchargeTaxCode.Items.FindByValue(_ShipMethod.SurchargeTaxCodeId.ToString()); if (item != null) { SurchargeTaxCode.SelectedIndex = SurchargeTaxCode.Items.IndexOf(item); } }
/// <summary> /// Deep load all ShipMethod children. /// </summary> private void Step_03_DeepLoad_Generated() { using (TransactionManager tm = CreateTransaction()) { int count = -1; mock = CreateMockInstance(tm); mockCollection = DataRepository.ShipMethodProvider.GetPaged(tm, 0, 10, out count); DataRepository.ShipMethodProvider.DeepLoading += new EntityProviderBaseCore <ShipMethod, ShipMethodKey> .DeepLoadingEventHandler( delegate(object sender, DeepSessionEventArgs e) { if (e.DeepSession.Count > 3) { e.Cancel = true; } } ); if (mockCollection.Count > 0) { DataRepository.ShipMethodProvider.DeepLoad(tm, mockCollection[0]); System.Console.WriteLine("ShipMethod instance correctly deep loaded at 1 level."); mockCollection.Add(mock); // DataRepository.ShipMethodProvider.DeepSave(tm, mockCollection); } //normally one would commit here //tm.Commit(); //IDisposable will Rollback Transaction since it's left uncommitted } }
public ShipMethodCollection GetAllShipMethodsDynamicCollection(string whereExpression, string orderBy) { IDBManager dbm = new DBManager(); ShipMethodCollection cols = new ShipMethodCollection(); try { dbm.CreateParameters(2); dbm.AddParameters(0, "@WhereCondition", whereExpression); dbm.AddParameters(1, "@OrderByExpression", orderBy); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectShipMethodsDynamic"); while (reader.Read()) { ShipMethod SM = new ShipMethod(); SM.ShipMethodID = Int32.Parse(reader["ShipMethodID"].ToString()); SM.Name = reader["Name"].ToString(); SM.ShipBase = decimal.Parse(reader["ShipBase"].ToString()); SM.ShipRate = decimal.Parse(reader["ShipRate"].ToString()); SM.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(SM); } } catch (Exception ex) { log.Write(ex.Message, "GetAllShipMethodsDynamicCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
public int AddShipMethod(ShipMethod SM) { IDBManager dbm = new DBManager(); try { dbm.CreateParameters(5); dbm.AddParameters(0, "@Name", SM.Name); dbm.AddParameters(1, "@ShipBase", SM.ShipBase); dbm.AddParameters(2, "@ShipRate", SM.ShipRate); dbm.AddParameters(3, "@ModifiedDate", DateTime.Now); dbm.AddParameters(4, "@ShipMethodID", SM.ShipMethodID); dbm.Parameters[4].Direction = ParameterDirection.Output; dbm.ExecuteNonQuery(CommandType.StoredProcedure, "InsertShipMethod"); SM.ShipMethodID = Int32.Parse(dbm.Parameters[4].Value.ToString()); } catch (Exception ex) { log.Write(ex.Message, "InsertShipMethod"); throw (ex); } finally { dbm.Dispose(); } return(SM.ShipMethodID); }
public ShipMethod GetShipMethod(int ShipMethodID) { IDBManager dbm = new DBManager(); ShipMethod SM = new ShipMethod(); try { dbm.CreateParameters(1); dbm.AddParameters(0, "@ShipMethodID", ShipMethodID); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectShipMethod"); while (reader.Read()) { SM.ShipMethodID = Int32.Parse(reader["ShipMethodID"].ToString()); SM.Name = reader["Name"].ToString(); SM.ShipBase = decimal.Parse(reader["ShipBase"].ToString()); SM.ShipRate = decimal.Parse(reader["ShipRate"].ToString()); SM.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); } } catch (Exception ex) { log.Write(ex.Message, "GetShipMethod"); throw (ex); } finally { dbm.Dispose(); } return(SM); }
public bool UpdateShipMethod(ShipMethod SM) { IDBManager dbm = new DBManager(); try { dbm.CreateParameters(5); dbm.AddParameters(0, "@ShipMethodID", SM.ShipMethodID); dbm.AddParameters(1, "@Name", SM.Name); dbm.AddParameters(2, "@ShipBase", SM.ShipBase); dbm.AddParameters(3, "@ShipRate", SM.ShipRate); dbm.AddParameters(4, "@ModifiedDate", DateTime.Now); dbm.ExecuteNonQuery(CommandType.StoredProcedure, "UpdateShipMethod"); } catch (Exception ex) { log.Write(ex.Message, "UpdateShipMethod"); throw (ex); } finally { dbm.Dispose(); } return(true); }
public ShipMethodCollection GetAllShipMethodsCollection() { IDBManager dbm = new DBManager(); ShipMethodCollection cols = new ShipMethodCollection(); try { IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectShipMethodAll"); while (reader.Read()) { ShipMethod SM = new ShipMethod(); SM.ShipMethodID = Int32.Parse(reader["ShipMethodID"].ToString()); SM.Name = reader["Name"].ToString(); SM.ShipBase = decimal.Parse(reader["ShipBase"].ToString()); SM.ShipRate = decimal.Parse(reader["ShipRate"].ToString()); SM.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(SM); } } catch (Exception ex) { log.Write(ex.Message, "GetAllShipMethodsCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
/// <summary> /// Ship an order to an address /// </summary> /// <param name="addressId">The Address ID, as obtained from AddressService</param> /// <param name="shipMethod">The shipping method</param> /// <param name="shipDate">The date that the order is to ship</param> /// <param name="dueDate">The date that the order is due to arrive with the customer</param> public void ShipToAddress(int addressId, ShipMethod shipMethod, DateTime shipDate, DateTime dueDate) { // connection is IDbConnection. Can be MySQL, SQLLite, Access, DB2, sybase, Oracle... This opens up a world of opportunity for exposing legacy code and systems to // your domain. var connection = GetConnection(); // note old skool proc name const string sql = "dbo.sp_soh_sh_addr_2"; // note horrible proc param names, translated from shiny interface names. // note translation of .NET DateTime to old skool date as string is done here. var result = connection.Query(sql, new { i_x_add_id = addressId, i_x_sh_m_id = (int)shipMethod, dt_sh_dt = shipDate.ToString("dd-MMM-yyyy"), dt_du_dt = dueDate.ToString("dd-MMM-yyyy") }, commandType: CommandType.StoredProcedure).First(); // note magic return number handling so that this method returns as successful, or throws. Magic numbers are researched and translated (and documented) here. switch ((int)result.RESULT_CODE) { case 0: System.Diagnostics.Trace.WriteLine(sql + " executed OK", "Info"); break; case -10: throw new InvalidOperationException("Order has already been shipped"); default: throw new InvalidOperationException("Unknown error in " + sql); } }
// GET: /ShipMethodMaster/Create public ActionResult Create() { ShipMethod vm = new ShipMethod(); vm.IsActive = true; return(View("Create", vm)); }
///<summary> /// Update the Typed ShipMethod Entity with modified mock values. ///</summary> static public void UpdateMockInstance(TransactionManager tm, ShipMethod mock) { ShipMethodTest.UpdateMockInstance_Generated(tm, mock); // make any alterations necessary // (i.e. for DB check constraints, special test cases, etc.) SetSpecialTestData(mock); }
public void ShipMethodQueryUsingoAuth() { QueryService <ShipMethod> entityQuery = new QueryService <ShipMethod>(qboContextoAuth); ShipMethod existing = Helper.FindOrAdd <ShipMethod>(qboContextoAuth, new ShipMethod()); List <ShipMethod> entities = entityQuery.Where(c => c.Id == existing.Id).ToList(); Assert.IsTrue(entities.Count() > 0); }
public void ShipMethodQueryUsingoAuth() { QueryService <ShipMethod> entityQuery = new QueryService <ShipMethod>(qboContextoAuth); ShipMethod existing = Helper.FindOrAdd <ShipMethod>(qboContextoAuth, new ShipMethod()); List <ShipMethod> entities = entityQuery.ExecuteIdsQuery("Select * from Customer where Id='" + existing.Id + "'").ToList(); Assert.IsTrue(entities.Count() > 0); }
protected void ShipmentCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "Recalc") { int itemId = AlwaysConvert.ToInt(e.CommandArgument); int index = _Order.Shipments.IndexOf(itemId); if (index > -1) { OrderShipment shipment = _Order.Shipments[index]; ShipMethod shipMethod = shipment.ShipMethod; if (shipMethod != null) { ShipRateQuote rate = shipMethod.GetShipRateQuote(shipment); if (rate != null) { // REMOVE OLD SHIPPING CHARGES FOR THIS SHIPMENT for (int i = _Order.Items.Count - 1; i >= 0; i--) { OrderItem item = _Order.Items[i]; if (item.OrderShipmentId == shipment.Id) { if (item.OrderItemType == OrderItemType.Shipping || item.OrderItemType == OrderItemType.Handling) { _Order.Items.DeleteAt(i); } } } // ADD NEW SHIPPING LINE ITEMS TO THE ORDER OrderItem shipRateLineItem = new OrderItem(); shipRateLineItem.OrderId = _Order.Id; shipRateLineItem.OrderItemType = OrderItemType.Shipping; shipRateLineItem.OrderShipmentId = shipment.Id; shipRateLineItem.Name = shipMethod.Name; shipRateLineItem.Price = rate.Rate; shipRateLineItem.Quantity = 1; shipRateLineItem.TaxCodeId = shipMethod.TaxCodeId; _Order.Items.Add(shipRateLineItem); if (rate.Surcharge > 0) { shipRateLineItem = new OrderItem(); shipRateLineItem.OrderId = _Order.Id; shipRateLineItem.OrderItemType = OrderItemType.Handling; shipRateLineItem.OrderShipmentId = shipment.Id; shipRateLineItem.Name = shipMethod.Name; shipRateLineItem.Price = rate.Surcharge; shipRateLineItem.Quantity = 1; shipRateLineItem.TaxCodeId = shipMethod.TaxCodeId; _Order.Items.Add(shipRateLineItem); } _Order.Save(true, false); BindGrids(); ShippingRecalculatedMessage.Visible = true; } } } } }
public void ShipMethodVoidAsyncTestsUsingoAuth() { //Creating the ShipMethod for Adding ShipMethod entity = QBOHelper.CreateShipMethod(qboContextoAuth); //Adding the ShipMethod ShipMethod added = Helper.Add <ShipMethod>(qboContextoAuth, entity); Helper.VoidAsync <ShipMethod>(qboContextoAuth, added); }
public void ShipMethodAddAsyncTestsUsingoAuth() { //Creating the ShipMethod for Add ShipMethod entity = QBOHelper.CreateShipMethod(qboContextoAuth); ShipMethod added = Helper.AddAsync <ShipMethod>(qboContextoAuth, entity); QBOHelper.VerifyShipMethod(entity, added); }
/// <summary> /// Indicates whether the given shipmethod is applicable on this BasketShipment or not /// </summary> /// <param name="shipMeth">The ship method to check</param> /// <returns><b>true</b> if ship method is applicable, <b>false</b> otherwise</returns> public bool IsShipMethodApplicable(ShipMethod shipMeth) { ShipMethodCollection shipMeths = this.ApplicableShipMethods; foreach (ShipMethod meth in shipMeths) { if (meth.ShipMethodId == shipMeth.ShipMethodId) return true; } return false; }
public void ShipMethodAddTestUsingoAuth() { //Creating the ShipMethod for Add ShipMethod shipMethod = QBOHelper.CreateShipMethod(qboContextoAuth); //Adding the ShipMethod ShipMethod added = Helper.Add <ShipMethod>(qboContextoAuth, shipMethod); //Verify the added ShipMethod QBOHelper.VerifyShipMethod(shipMethod, added); }
// GET: /ProductMaster/Edit/5 public ActionResult Edit(int id) { ShipMethod pt = _ShipMethodService.Find(id); if (pt == null) { return(HttpNotFound()); } return(View("Create", pt)); }
public void ShipMethodFindbyIdTestUsingoAuth() { //Creating the ShipMethod for Adding ShipMethod shipMethod = QBOHelper.CreateShipMethod(qboContextoAuth); //Adding the ShipMethod ShipMethod added = Helper.Add <ShipMethod>(qboContextoAuth, shipMethod); ShipMethod found = Helper.FindById <ShipMethod>(qboContextoAuth, added); QBOHelper.VerifyShipMethod(found, added); }
public void Map(ShipMethod entity) { if (entity == null) { return; } entity.Id = Id; entity.Name = Name ?? entity.Name; }
protected string GetMaxPurchase(object dataItem) { ShipMethod method = (ShipMethod)dataItem; if (method.MaxPurchase > 0) { return(method.MaxPurchase.LSCurrencyFormat("lc")); } return(string.Empty); }
/// <summary> /// Check the foreign key dal methods. /// </summary> private void Step_10_FK_Generated() { using (TransactionManager tm = CreateTransaction()) { ShipMethod entity = CreateMockInstance(tm); bool result = DataRepository.ShipMethodProvider.Insert(tm, entity); Assert.IsTrue(result, "Could Not Test FK, Insert Failed"); } }
private string BuildShipMethodName(ShipMethod shipMethod, List <string> shipMethodsAdded) { string methName = AcHelper.SanitizeText(shipMethod.Name); if (shipMethodsAdded.Contains(methName.ToLowerInvariant())) { methName = string.Format("[{0}]{1}", shipMethod.Id, methName); } return(methName); }
public ShipMethodBuilder WithTestValues() { shipMethod = new ShipMethod { Name = "CARGO TRANSPORT 5", ShipBase = 8.99M, ShipRate = 1.49M }; return(this); }
/// <summary> /// Test methods exposed by the EntityHelper class. /// </summary> private void Step_20_TestEntityHelper_Generated() { using (TransactionManager tm = CreateTransaction()) { mock = CreateMockInstance(tm); ShipMethod entity = mock.Copy() as ShipMethod; entity = (ShipMethod)mock.Clone(); Assert.IsTrue(ShipMethod.ValueEquals(entity, mock), "Clone is not working"); } }
private static LineItemModel ToLineItemModel(this ShipMethod method, Address shipFrom, Address shipTo) { return(new LineItemModel() { amount = method.Cost, taxCode = "FR", itemCode = method.Name, customerUsageType = null, number = method.ID, addresses = ToAddressesModel(shipFrom, shipTo) }); }
// PUT api/awbuildversion/5 public void Put(ShipMethod value) { var GetActionType = Request.Headers.Where(x => x.Key.Equals("ActionType")).FirstOrDefault(); if (GetActionType.Key != null) { if (GetActionType.Value.ToList()[0].Equals("DELETE")) adventureWorks_BC.ShipMethodDelete(value); if (GetActionType.Value.ToList()[0].Equals("UPDATE")) adventureWorks_BC.ShipMethodUpdate(value); } }
protected void AddShipMethodButton_Click(object sender, EventArgs e) { if (Page.IsValid) { ShipMethod method = new ShipMethod(); string selectedMethodType = AddShipMethodType.SelectedValue; method.ShipMethodType = ((ShipMethodType)(AlwaysConvert.ToInt16(AddShipMethodType.SelectedValue))); method.Name = AddShipMethodName.Text; method.Save(); Response.Redirect(GetEditUrl(method)); } }
/// <summary> /// Creates a <see cref="IShipMethod"/>. This is useful due to the data constraint /// preventing two ShipMethods being created with the same ShipCountry and ServiceCode for any provider. /// </summary> /// <param name="providerKey">The unique gateway provider key (Guid)</param> /// <param name="shipCountry">The <see cref="IShipCountry"/> this ship method is to be associated with</param> /// <param name="name">The required name of the <see cref="IShipMethod"/></param> /// <param name="serviceCode">The ShipMethods service code</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> internal Attempt<IShipMethod> CreateShipMethodWithKey(Guid providerKey, IShipCountry shipCountry, string name, string serviceCode, bool raiseEvents = true) { Mandate.ParameterCondition(providerKey != Guid.Empty, "providerKey"); Mandate.ParameterNotNull(shipCountry, "shipCountry"); Mandate.ParameterNotNullOrEmpty(name, "name"); Mandate.ParameterNotNullOrEmpty(serviceCode, "serviceCode"); if (ShipMethodExists(providerKey, shipCountry.Key, serviceCode)) return Attempt<IShipMethod>.Fail(new ConstraintException("A Shipmethod already exists for this ShipCountry with this ServiceCode")); var shipMethod = new ShipMethod(providerKey, shipCountry.Key) { Name = name, ServiceCode = serviceCode, Provinces = shipCountry.Provinces.ToShipProvinceCollection() }; if(raiseEvents) if (Creating.IsRaisedEventCancelled(new Events.NewEventArgs<IShipMethod>(shipMethod), this)) { shipMethod.WasCancelled = true; return Attempt<IShipMethod>.Fail(shipMethod); } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateShipMethodRepository(uow)) { repository.AddOrUpdate(shipMethod); uow.Commit(); } } if(raiseEvents) Created.RaiseEvent(new Events.NewEventArgs<IShipMethod>(shipMethod), this); return Attempt<IShipMethod>.Succeed(shipMethod); }
// POST api/awbuildversion public void Post(ShipMethod value) { adventureWorks_BC.ShipMethodAdd(value); }
public static ShipMethod CreateShipMethod(int shipMethodID, int warehouseID, int shipCarrierID, bool displayOnWeb) { ShipMethod shipMethod = new ShipMethod(); shipMethod.ShipMethodID = shipMethodID; shipMethod.WarehouseID = warehouseID; shipMethod.ShipCarrierID = shipCarrierID; shipMethod.DisplayOnWeb = displayOnWeb; return shipMethod; }
public static ShipMethod CreateShipMethod(int shipMethodID, int warehouseID) { ShipMethod shipMethod = new ShipMethod(); shipMethod.ShipMethodID = shipMethodID; shipMethod.WarehouseID = warehouseID; return shipMethod; }
public void AddToShipMethods(ShipMethod shipMethod) { base.AddObject("ShipMethods", shipMethod); }
/// <summary> /// Create a new ShipMethod object. /// </summary> /// <param name="shipMethodID">Initial value of ShipMethodID.</param> /// <param name="name">Initial value of Name.</param> /// <param name="shipBase">Initial value of ShipBase.</param> /// <param name="shipRate">Initial value of ShipRate.</param> /// <param name="rowguid">Initial value of rowguid.</param> /// <param name="modifiedDate">Initial value of ModifiedDate.</param> public static ShipMethod CreateShipMethod(int shipMethodID, string name, decimal shipBase, decimal shipRate, global::System.Guid rowguid, global::System.DateTime modifiedDate) { ShipMethod shipMethod = new ShipMethod(); shipMethod.ShipMethodID = shipMethodID; shipMethod.Name = name; shipMethod.ShipBase = shipBase; shipMethod.ShipRate = shipRate; shipMethod.rowguid = rowguid; shipMethod.ModifiedDate = modifiedDate; return shipMethod; }