public CarModel getCarData() { EmiDetails e = new EmiDetails { cost = "10,719", duration = "5 years" }; ReviewDetails r = new ReviewDetails { rating = 3, totalReviewCount = 312 }; PriceDetails p = new PriceDetails { price = "6.62 Lakhs", carType = "On - Road, Mumbai" }; CarModel model = new CarModel { ReviewDetail = r, EmiDetail = e, PriceDetail = p, cityList = getCityList(), versionList = getVersionList(), name = "BMW M2", imageUrl = "https://imgd.aeplcdn.com/664x374/n/cw/ec/26742/swift-exterior-right-front-three-quarter-117655.gif?q=85" }; return(model); }
private void CalculatePrice() { var totalPrice = 0.0; foreach (var parcel in _parcels.Values) { parcel.SetShippingPrice(ShippingRatesByCode); PriceDetails.AppendFormat($"{parcel.Name} parcel price : {parcel.TotalPrice}.\n"); TotalPrice += parcel.TotalPrice; } ICalculateDiscounts orderDiscount = new object() as ICalculateDiscounts; Discounts = CalculateDiscounts(orderDiscount); TotalDiscount = Discounts.Sum(discount => discount.Value); TotalPrice -= TotalDiscount; if (Speedy) { SpeedyShippingPrice = totalPrice; TotalPrice += SpeedyShippingPrice; } }
public void SavePriceDetails(PriceDetails priceDetails) { var dateNow = DateTime.Now; using (var context = contextMaker.Invoke()) { context.PriceDetails.Add(priceDetails); context.SaveChanges(); } }
private static TeamOdds BuildTeamOdds(string id) { var rnd = new Random(); var price = rnd.Next(1, 100); var priceDetails = new PriceDetails { Price = price / 10 }; return(new TeamOdds { SelectionId = id, Exchange = new Exchange { AvailableToBack = new[] { priceDetails } } }); }
public string PrintOrderPrice() { if (Speedy) { PriceDetails.AppendLine("=========== SpeedyShippingDelivery ==========="); PriceDetails.AppendFormat($"Order price is {TotalPrice}\n\n"); PriceDetails.AppendFormat("Order speedy price is {SpeedyShippingPrice}\n\n"); } else { PriceDetails.AppendLine("=========== RegularShippingDelivery ==========="); PriceDetails.AppendFormat($"Order price is {TotalPrice}\n\n"); } PriceDetails.AppendFormat($"Total Discounts : {TotalDiscount}\n\n"); return(PriceDetails.ToString()); }
public PriceDetails GetShoppingCartDetails(ShoppingCart shoppingCart) { var selectedProducts = shoppingCart.CartProducts.Select(id => productService.GetProductDetails(id)).ToList(); var totalResult = new PriceDetails { SelectedProducts = selectedProducts }; foreach (var product in selectedProducts) { totalResult.TotalPrice += product.Price; } //apply rebate of 10% if total exceeds 20M if (totalResult.TotalPrice > 20M) { totalResult.RebateValue = totalResult.TotalPrice * 0.1M; totalResult.DiscountedPrice = totalResult.TotalPrice - totalResult.RebateValue; } return(totalResult); }
public void SavePrices(IEnumerable <PriceParserResult> priceData) { var dateNow = DateTime.Now; var priceSeries = new List <PriceSeries>(); var dbPriceDetails = priceRepository.GetPriceDetails(); foreach (var price in priceData) { var priceSerie = new PriceSeries(); priceSerie.CreatedDate = dateNow; priceSerie.ParserId = price.ParserConfigId; priceSerie.Price = price.Price; var existingPriceDetail = dbPriceDetails .Where(pd => pd.RetailerNo == price.ProductNo) .OrderByDescending(pd => pd.Id) .FirstOrDefault(); if (existingPriceDetail == null) { var priceDetailsItem = new PriceDetails(); priceDetailsItem.Title = price.Title; priceDetailsItem.RetailerNo = price.ProductNo; priceDetailsItem.CreatedDate = dateNow; priceRepository.SavePriceDetails(priceDetailsItem); existingPriceDetail = priceDetailsItem; } priceSerie.PriceDetailsId = existingPriceDetail.Id; priceSeries.Add(priceSerie); } priceRepository.SavePrices(priceSeries); }
public PriceDetails GetPrice(string distance, string lorryType, string fromBuildingType = null, string toBuildingType = null, string labor = null, string assembleBed = null, string assemblyDining = null, string assemblyWardrobe = null, string assemblyTable = null, string bubbleWrapping = null, string shrinkWrapping = null, string promoCode = null) { // calculate the transport cost var transportCost = deliveryPriceDao.GetPrice(distance, lorryType); if (transportCost == null) { return(null); } PriceDetails priceDetails = new PriceDetails(); priceDetails.total = transportCost.price; priceDetails.partnerTotal = transportCost.partner_price; // break down the cost priceDetails.fuel = 0.4f * priceDetails.partnerTotal; priceDetails.maintenance = 0.35f * priceDetails.partnerTotal; priceDetails.labor = 0.25f * priceDetails.partnerTotal; var additionalService = deliveryAdditionalDao.Get(); int laborCount = 0; if (fromBuildingType != null && toBuildingType != null && labor != null && int.TryParse(labor, out laborCount) && laborCount != 0) { DeliveryExtraService laborCost = null; // extra labor cost if (int.Parse(fromBuildingType) == (int)Constants.Configuration.BuildingType.HighRise_nolift || int.Parse(toBuildingType) == (int)Constants.Configuration.BuildingType.HighRise_nolift) { laborCost = additionalService.Find(t => t.name.CompareTo("labor-highrise-nolift") == 0); } else if (int.Parse(fromBuildingType) == (int)Constants.Configuration.BuildingType.HighRise_lift || int.Parse(toBuildingType) == (int)Constants.Configuration.BuildingType.HighRise_lift) { laborCost = additionalService.Find(t => t.name.CompareTo("labor-highrise-lift") == 0); } else { laborCost = additionalService.Find(t => t.name.CompareTo("labor-landed") == 0); } if (laborCost == null) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, fromBuildingType + " " + toBuildingType); return(null); } var addCost = laborCount * laborCost.value; var addPartnerCost = laborCount * laborCost.partnerValue; priceDetails.total += addCost; priceDetails.partnerTotal += addPartnerCost; priceDetails.labor += addPartnerCost; } int assembleBedCount = 0; if (assembleBed != null && int.TryParse(assembleBed, out assembleBedCount) && assembleBedCount != 0) { var cost = additionalService.Find(t => t.name.CompareTo("assemble-bed") == 0); if (cost == null) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "assembleBed: " + assembleBed); return(null); } var addCost = assembleBedCount * cost.value; var addPartnerCost = assembleBedCount * cost.partnerValue; priceDetails.total += addCost; priceDetails.partnerTotal += addPartnerCost; priceDetails.labor += addPartnerCost; } int assembleDiningCount = 0; if (assemblyDining != null && int.TryParse(assemblyDining, out assembleDiningCount) && assembleDiningCount != 0) { var cost = additionalService.Find(t => t.name.CompareTo("assemble-diningtable") == 0); if (cost == null) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "assembleBed: " + assemblyDining); return(null); } var addCost = assembleDiningCount * cost.value; var addPartnerCost = assembleDiningCount * cost.partnerValue; priceDetails.total += addCost; priceDetails.partnerTotal += addPartnerCost; priceDetails.labor += addPartnerCost; } int assembleTableCount = 0; if (assemblyTable != null && int.TryParse(assemblyTable, out assembleTableCount) && assembleTableCount != 0) { var cost = additionalService.Find(t => t.name.CompareTo("assemble-table") == 0); if (cost == null) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "assemblyTable: " + assemblyTable); return(null); } var addCost = assembleTableCount * cost.value; var addPartnerCost = assembleTableCount * cost.partnerValue; priceDetails.total += addCost; priceDetails.partnerTotal += addPartnerCost; priceDetails.labor += addPartnerCost; } int assemblyWardrobeCount = 0; if (assemblyWardrobe != null && int.TryParse(assemblyWardrobe, out assemblyWardrobeCount) && assemblyWardrobeCount != 0) { var cost = additionalService.Find(t => t.name.CompareTo("assemble-wardrobe") == 0); if (cost == null) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "assemblyWardrobe: " + assemblyWardrobe); return(null); } var addCost = assemblyWardrobeCount * cost.value; var addPartnerCost = assemblyWardrobeCount * cost.partnerValue; priceDetails.total += addCost; priceDetails.partnerTotal += addPartnerCost; priceDetails.labor += addPartnerCost; } int bubbleWrappingCount = 0; if (bubbleWrapping != null && int.TryParse(bubbleWrapping, out bubbleWrappingCount) && bubbleWrappingCount != 0) { var cost = additionalService.Find(t => t.name.CompareTo("bubble-wrap") == 0); if (cost == null) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "bubbleWrapping: " + bubbleWrapping); return(null); } var addCost = bubbleWrappingCount * cost.value; var addPartnerCost = bubbleWrappingCount * cost.partnerValue; priceDetails.total += addCost; priceDetails.partnerTotal += addPartnerCost; } int shrinkWrappingCount = 0; if (shrinkWrapping != null && int.TryParse(shrinkWrapping, out shrinkWrappingCount) && shrinkWrappingCount != 0) { var cost = additionalService.Find(t => t.name.CompareTo("shrink-wrap") == 0); if (cost == null) { DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "shrinkWrapping: " + shrinkWrapping); return(null); } var addCost = shrinkWrappingCount * cost.value; var addPartnerCost = shrinkWrappingCount * cost.partnerValue; priceDetails.total += addCost; priceDetails.partnerTotal += addPartnerCost; } priceDetails.partner = priceDetails.partnerTotal; priceDetails.justlorry = priceDetails.total - priceDetails.partnerTotal; // discount voucher if (promoCode != null) { var voucherResult = new Vouchers(); var responseCode = validateVoucher(promoCode, priceDetails.total, out voucherResult); if (responseCode == Constant.ErrorCode.ESuccess) { // first set the used voucher count // 20161118 - increase count during confirm (add job) instead //if (voucherDao.IncreaseUsedCount(promoCode) == false) //{ // DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "voucherDao.IncreaseUsedCount(promoCode) in Common controller: " + promoCode); //} if (int.Parse(voucherResult.voucherType.id) == (int)Constants.Configuration.VoucherType.Percentage) { var discountedValue = voucherResult.discountValue * priceDetails.total; if (discountedValue > voucherResult.maximumDiscount) { discountedValue = voucherResult.maximumDiscount; } priceDetails.total -= discountedValue; priceDetails.discount = discountedValue; priceDetails.discountRate = (int)voucherResult.discountValue; } else if (int.Parse(voucherResult.voucherType.id) == (int)Constants.Configuration.VoucherType.Value) { var discountedValue = voucherResult.discountValue; if (discountedValue > voucherResult.maximumDiscount) { discountedValue = voucherResult.maximumDiscount; } priceDetails.discountRate = (int)(voucherResult.discountValue / priceDetails.total); priceDetails.total -= discountedValue; priceDetails.discount = discountedValue; } } } if (priceDetails.total < 0) { priceDetails.total = 0; } return(priceDetails); }
/// <summary> /// To add price detail of the record based on ZCRMPriceBookPricing class instance. /// </summary> /// <param name="priceDetail">ZCRMPriceBookPricing class instance</param> public void AddPriceDetail(ZCRMPriceBookPricing priceDetail) { PriceDetails.Add(priceDetail); }
public PriceDetailsDecorator(PriceDetails component) { _component = component ?? new PriceDetails(); }
public PriceDetails GetPrice(string lorryType, string fromBuildingType, string promoCode) { var transportCost = deliveryPriceDao.GetPrice("0", lorryType); if (transportCost == null) { return(null); } PriceDetails priceDetails = new PriceDetails(); priceDetails.total = (transportCost.price * 0.8f); priceDetails.partnerTotal = (transportCost.partner_price * 0.8f); // breakdown cost priceDetails.fuel = 0.4f * priceDetails.partnerTotal; priceDetails.maintenance = 0.35f * priceDetails.partnerTotal; priceDetails.labor = 0.25f * priceDetails.partnerTotal; // calculate for labors var laborCount = 1; switch (lorryType) { case "1": laborCount = 2; break; case "2": case "3": laborCount = 3; break; } var additionalService = deliveryAdditionalDao.Get(); DeliveryExtraService laborCost = null; // extra labor cost if (fromBuildingType == null) { fromBuildingType = "1"; } if (int.Parse(fromBuildingType) == (int)Constants.Configuration.BuildingType.HighRise_nolift) { laborCost = additionalService.Find(t => t.name.CompareTo("labor-highrise-nolift") == 0); } else if (int.Parse(fromBuildingType) == (int)Constants.Configuration.BuildingType.HighRise_lift) { laborCost = additionalService.Find(t => t.name.CompareTo("labor-highrise-lift") == 0); } else { laborCost = additionalService.Find(t => t.name.CompareTo("labor-landed") == 0); } if (laborCost == null) { return(null); } var laborCosting = laborCount * laborCost.value; var partnerLaborCosting = laborCount * laborCost.partnerValue; priceDetails.total += laborCosting; priceDetails.partnerTotal += partnerLaborCosting; priceDetails.labor += partnerLaborCosting; priceDetails.partner = priceDetails.partnerTotal; priceDetails.justlorry = (priceDetails.total - priceDetails.partnerTotal); // discount voucher if (promoCode != null) { var voucherResult = new Vouchers(); var responseCode = validateVoucher(promoCode, priceDetails.total, out voucherResult); if (responseCode == Constant.ErrorCode.ESuccess) { // first set the used voucher count // 20161118 - increase count during confirm (add job) instead //if (voucherDao.IncreaseUsedCount(promoCode) == false) //{ // DBLogger.GetInstance().Log(DBLogger.ESeverity.Warning, "voucherDao.IncreaseUsedCount(promoCode) in Common controller: " + promoCode); //} if (int.Parse(voucherResult.voucherType.id) == (int)Constants.Configuration.VoucherType.Percentage) { var discountedValue = voucherResult.discountValue * priceDetails.total; if (discountedValue > voucherResult.maximumDiscount) { discountedValue = voucherResult.maximumDiscount; } priceDetails.total -= discountedValue; priceDetails.discount = discountedValue; priceDetails.discountRate = (int)voucherResult.discountValue; } else if (int.Parse(voucherResult.voucherType.id) == (int)Constants.Configuration.VoucherType.Value) { var discountedValue = voucherResult.discountValue; if (discountedValue > voucherResult.maximumDiscount) { discountedValue = voucherResult.maximumDiscount; } priceDetails.discountRate = (int)(voucherResult.discountValue / priceDetails.total); priceDetails.total -= discountedValue; priceDetails.discount = discountedValue; } } } return(priceDetails); }