public List <ProjectDetail> GetEstimationsByID(int id) { PricingHelper helper = new PricingHelper(); List <ProjectDetail> detail = helper.GetEstimationDetailsByID(id); return(detail); }
public List <ProjectDetail> GetEstimationsByEmail(string email) { PricingHelper helper = new PricingHelper(); List <ProjectDetail> detail = helper.GetEstimationDetailsByEmail(email); return(detail); }
public string GetPrice(string Category, string SubCategory, string Region) { PricingHelper helper = new PricingHelper(); string price = helper.GetPriceDetails(Category, SubCategory, Region); return((Convert.ToDouble(price) * 744).ToString()); }
public void CalculatePricesTest() { Dictionary <string, Dictionary <string, JOffer> > pdfRates = new Rates().GetRates(sf, out site); string brokerName = "JIG"; // for (int i = 0; i < Classes.Count(); i++) { PricingHelper ph = new PricingHelper(); List <JOffer> categoryOffers = new PricingHelper().GetMiniRatesList(pdfRates, "EconomyA"); List <JOffer> higherOffers = new PricingHelper().GetMiniRatesList(pdfRates, "CompactM"); List <float> fuseRates = new CsvHelper("314141").GetFuseRates(brokerName); PricingClass[] classes = new PricingClass[5]; PricingHelper hp = new PricingHelper(new PricingModel(), classes); List <float> priceList = hp.CalculatePrices(categoryOffers, higherOffers, fuseRates, brokerName); Console.WriteLine("-----------------"); for (int i = 0; i < priceList.Count; i++) { JOffer tempOffer = categoryOffers.Count > i?categoryOffers.ElementAt(i) : null; float price = tempOffer != null?tempOffer.GetMinPrice() : 0; float gmPrice = tempOffer != null?tempOffer.GetMinGmPrice() : 0; Console.WriteLine(i + " price " + price + " gmprice " + gmPrice + " fuse: " + fuseRates.ElementAt(i) + " new price: " + priceList.ElementAt(i)); } Console.WriteLine("-----------------"); Console.ReadLine(); } }
public static List <ShoppingCartItemReportModel> ToReportModel(this List <ShoppingCartItem> items) { List <ShoppingCartItemReportModel> newList = new List <ShoppingCartItemReportModel>(); foreach (ShoppingCartItem i in items) { ShoppingCartItemReportModel n = new ShoppingCartItemReportModel(); n.ItemNumber = i.ItemNumber; n.Name = i.Name; n.Brand = i.Brand; n.Category = i.ItemClass; n.PackSize = i.PackSize; if (i.Notes != null) { n.Notes = i.Notes; } n.Label = i.Label; n.ParLevel = i.ParLevel; n.Quantity = i.Quantity; n.Each = i.Each; n.CasePrice = i.CasePrice.ToDouble().Value; n.PackagePrice = i.PackagePrice.ToDouble().Value; n.ExtPrice = PricingHelper.GetPrice((int)i.Quantity, i.CasePriceNumeric, i.PackagePriceNumeric, i.Each, i.CatchWeight, i.AverageWeight, i.Pack.ToInt(1)); newList.Add(n); } return(newList); }
public string SavePricingData() { var httpRequest = HttpContext.Current.Request; dynamic projectDetails = JsonConvert.DeserializeObject <object>(httpRequest.Params["ProjectDetails"]); ProjectDetail detail = projectDetails.ToObject <ProjectDetail>(); PricingHelper helper = new PricingHelper(); helper.SaveProjectPricingDetais(detail); return("success"); }
public ApprovedCartModel ValidateCart(UserProfile user, UserSelectedContext catalogInfo, Guid cartId, string orderNumber) { ApprovedCartModel ret = new ApprovedCartModel(); bool isCart = cartId != null && cartId != Guid.Empty ? true : false; if (isCart == true) { Core.Models.ShoppingCart.ShoppingCart currentCart = new Core.Models.ShoppingCart.ShoppingCart(); } else { Core.Models.Orders.Order existingOrder = new Core.Models.Orders.Order(); } try { MinimumOrderAmountModel minimumOrderAmount = _minimumAmountRepo.GetMinimumOrderAmount(catalogInfo.CustomerId, catalogInfo.BranchId); decimal subtotal = 0; ret.ApprovedAmount = minimumOrderAmount.ApprovedAmount; if (isCart == true) { currentCart = _shoppingCartLogic.ReadCart(user, catalogInfo, cartId); subtotal = (decimal)PricingHelper.CalculateCartSubtotal(currentCart.Items); } else { existingOrder = _orderLogic.ReadOrder(user, catalogInfo, orderNumber, false); subtotal = (decimal)existingOrder.OrderTotal; } ret.Approved = ret.ApprovedAmount <= subtotal; ret.RemainingAmount = ret.ApprovedAmount - subtotal > 0 ? ret.ApprovedAmount - subtotal : 0; if (ret.Approved == false) { throw new Exception("The cart total does not meet or exceed the minimum approved amount. Please contact your DSR for more information."); } } catch (Exception ex) { _log.WriteErrorLog("ValidateCart", ex); ret.Message = ex.Message; ret.Approved = false; } return(ret); }
public decimal Calculate(List <CartItem> cartItems) { if (cartItems == null) { throw new ArgumentNullException(nameof(cartItems)); } foreach (var cartItem in cartItems) { CalculateLineTotal(cartItem); } var total = cartItems.Sum(a => a.LineTotal); return(PricingHelper.RoundPrice(total)); }
public string InitiateDates(PricingModel searchFilters) { if (ModelState.IsValid) { DbUpdates.UpdatedRates(searchFilters, User.Identity.Name); PricingHelper pr = new PricingHelper(searchFilters, allClasses.Where(s => s.LocationId == searchFilters.Location && s.IntervalNum == searchFilters.IntervalNum && searchFilters.Classes.FirstOrDefault().Contains(s.ClassName)).ToArray()); return(pr.SetDates()); } else { return(""); } }
private static decimal GetLinePrice(OrderLineChange line, Product currentProduct, Price price) { if (currentProduct != null && currentProduct.CatchWeight) { if (line.Each) //package catchweight { return((decimal)PricingHelper.GetCatchweightPriceForPackage (line.QuantityShipped, int.Parse(currentProduct.Pack), currentProduct.AverageWeight, price.PackagePrice)); } else //case catchweight { return((decimal)PricingHelper.GetCatchweightPriceForCase (line.QuantityShipped, currentProduct.AverageWeight, price.CasePrice)); } } else { return(line.QuantityShipped * line.ItemPrice); } }
/// <summary> /// Converts listitems to ShoppingCartItemReportModel /// </summary> /// <param name="list"></param> /// <returns></returns> public static List <ShoppingCartItemReportModel> ToShoppingCartItemReportList(this PagedListModel list) { List <ShoppingCartItemReportModel> items = new List <ShoppingCartItemReportModel>(); if (list.Items != null && list.Items.Results != null) { foreach (ListItemModel i in list.Items.Results) { ShoppingCartItemReportModel item = new ShoppingCartItemReportModel(); item.ItemNumber = i.ItemNumber; item.Name = i.Name; item.Brand = i.BrandExtendedDescription; item.Category = i.ItemClass; item.PackSize = i.PackSize; if (i.Notes != null) { item.Notes = i.Notes; } item.Label = i.Label; item.ParLevel = i.ParLevel; item.Quantity = i.Quantity; item.Each = i.Each; item.CasePrice = i.CasePrice.ToDouble().Value; item.PackagePrice = i.PackagePrice.ToDouble().Value; item.ExtPrice = PricingHelper.GetPrice((int)i.Quantity, i.CasePriceNumeric, i.PackagePriceNumeric, (i.Each ?? false), i.CatchWeight, i.AverageWeight, i.Pack.ToInt(1)); items.Add(item); } } return(items); }
public string GeneratePrices(SearchFilters searchFilters) { string linkNr = string.Empty; if (searchFilters.Location == 1) { linkNr = "291345"; } if (searchFilters.Location == 12) { linkNr = "290494"; } if (string.IsNullOrEmpty(linkNr)) { throw new Exception(); } PricingHelper pr = new PricingHelper(searchFilters, new string[] { "MiniM" /*, "EconomyM", "EconomyA", "CompactM", "CompactA"*/ }, new string[] { linkNr /*, "283487", "283488", "283489", "283490"*/ }); return("ok"); }
public string GeneratePrices(PricingModel searchFilters) { try { if (ModelState.IsValid) { DbUpdates.UpdatedRates(searchFilters, User.Identity.Name); PricingHelper pr = new PricingHelper(searchFilters, allClasses.Where(s => s.LocationId == searchFilters.Location && s.IntervalNum == searchFilters.IntervalNum && searchFilters.Classes.FirstOrDefault().Contains(s.ClassName)).ToArray()); return(pr.Excecute()); } else { return(""); } } catch (Exception ex) { Log.Instance.Error("--- " + ex.Message + "\n " + ex.InnerException + "\n" + ex.StackTrace); return(""); } }