public List <IShippingRate> RateShipment(IShipment shipment) { var totalItems = 0; foreach (var item in shipment.Items) { totalItems += item.QuantityOfItemsInBox; } decimal amount = 0; if (Settings != null) { if (Settings.GetLevels() != null) { var level = RateTableLevel.FindRateForLevel(totalItems, Settings.GetLevels()); if (level != null && level.Rate >= 0) { amount = level.Rate; } } } var r = new ShippingRate { ServiceId = Id, EstimatedCost = amount }; var rates = new List <IShippingRate> { r }; return(rates); }
public List <IShippingRate> RateShipment(IShipment shipment) { decimal totalWeight = 0; foreach (var item in shipment.Items) { totalWeight += item.BoxWeight; } decimal amount = 0; if (Settings != null) { if (Settings.GetLevels() != null) { var level = RateTableLevel.FindRateForLevel(totalWeight, Settings.GetLevels()); amount = level.Rate; } } var r = new ShippingRate { ServiceId = Id, EstimatedCost = amount }; var rates = new List <IShippingRate> { r }; return(rates); }
public List <IShippingRate> RateShipment(IShipment shipment) { decimal totalValue = 0; foreach (IShippable item in shipment.Items) { totalValue += item.BoxValue; } decimal amount = 0; if (Settings != null) { if (Settings.GetLevels() != null) { amount = RateTableLevel.FindRateFromLevels(totalValue, Settings.GetLevels()); } } ShippingRate r = new ShippingRate(); r.ServiceId = this.Id; r.EstimatedCost = amount; List <IShippingRate> rates = new List <IShippingRate>(); rates.Add(r); return(rates); }
public List <IShippingRate> RateShipment(IShipment shipment) { int totalItems = 0; foreach (IShippable item in shipment.Items) { totalItems += item.QuantityOfItemsInBox; } decimal amountPerItem = 0; if (Settings != null) { if (Settings.GetLevels() != null) { amountPerItem = RateTableLevel.FindRateFromLevels(totalItems, Settings.GetLevels()); } } ShippingRate r = new ShippingRate(); r.ServiceId = this.Id; r.EstimatedCost = amountPerItem * totalItems; List <IShippingRate> rates = new List <IShippingRate>(); rates.Add(r); return(rates); }
public bool RemoveLevel(RateTableLevel r) { bool result = false; List<RateTableLevel> levels = GetLevels(); result = levels.Remove(r); SaveLevelsToSettings(levels); return result; }
public bool RemoveLevel(RateTableLevel r) { var result = false; var levels = GetLevels(); result = levels.Remove(r); SaveLevelsToSettings(levels); return(result); }
protected void btnNew_Click(object sender, System.Web.UI.ImageClickEventArgs e) { RateTableLevel r = new RateTableLevel(); r.Level = decimal.Parse(this.NewLevelField.Text); r.Rate = decimal.Parse(this.NewAmountField.Text); RateTableSettings settings = new RateTableSettings(); settings.Merge(ShippingMethod.Settings); settings.AddLevel(r); ShippingMethod.Settings = settings; MyPage.MTApp.OrderServices.ShippingMethods.Update(ShippingMethod); LoadLevels(); }
private void RemoveLevel(string level, string rate) { RateTableSettings settings = new RateTableSettings(); settings.Merge(ShippingMethod.Settings); RateTableLevel r = new RateTableLevel(); r.Level = decimal.Parse(level); r.Rate = decimal.Parse(rate, System.Globalization.NumberStyles.Currency); settings.RemoveLevel(r); ShippingMethod.Settings = settings; MyPage.MTApp.OrderServices.ShippingMethods.Update(ShippingMethod); LoadLevels(); }
private void RemoveLevel(string level, string rate) { var settings = new RateTableSettings(); settings.Merge(ShippingMethod.Settings); var r = new RateTableLevel { Level = decimal.Parse(level), Rate = decimal.Parse(rate, NumberStyles.Currency) }; settings.RemoveLevel(r); ShippingMethod.Settings = settings; HccApp.OrderServices.ShippingMethods.Update(ShippingMethod); LoadLevels(); }
protected void btnNew_Click(object sender, EventArgs e) { var r = new RateTableLevel { Level = decimal.Parse(NewLevelField.Text), Rate = decimal.Parse(NewAmountField.Text) }; var settings = new RateTableSettings(); settings.Merge(ShippingMethod.Settings); settings.AddLevel(r); ShippingMethod.Settings = settings; HccApp.OrderServices.ShippingMethods.Update(ShippingMethod); LoadLevels(); }
public bool AddLevel(RateTableLevel r) { var levels = GetLevels(); var found = false; foreach (var sl in levels) { if (sl.Level == r.Level) { sl.Rate = r.Rate; found = true; break; } } if (found == false) { levels.Add(r); } SaveLevelsToSettings(levels); return(true); }
public bool AddLevel(RateTableLevel r) { List<RateTableLevel> levels = GetLevels(); bool found = false; foreach (RateTableLevel sl in levels) { if (sl.Level == r.Level) { sl.Rate = r.Rate; found = true; break; } } if (found == false) { levels.Add(r); } SaveLevelsToSettings(levels); return true; }
public List <IShippingRate> RateShipment(IShipment shipment) { decimal totalValue = 0; foreach (var item in shipment.Items) { totalValue += item.BoxValue; } decimal amount = 0; if (Settings != null) { if (Settings.GetLevels() != null) { var level = RateTableLevel.FindRateForLevel(totalValue, Settings.GetLevels()); if (level != null && level.Rate >= 0) { amount = level.Rate; var percent = totalValue * (level.Percent / 100); amount += percent; } } } var r = new ShippingRate { ServiceId = Id, EstimatedCost = amount }; var rates = new List <IShippingRate> { r }; return(rates); }