public decimal PriceWithAdjustments() { var result = BasePrice; result += DiscountDetails.Sum(y => y.Amount); return(result); }
/// <summary> /// Total of all discounts /// </summary> /// <returns>Decimal</returns> public decimal TotalDiscounts() { if (DiscountDetails == null || DiscountDetails.Count < 1) { return(0); } return(IsFreeItem ? DiscountDetails.Where(s => s.DiscountType == PromotionType.OfferForFreeItems).Sum(y => y.Amount) : DiscountDetails.Sum(y => y.Amount)); }
private void LoadRecord() { Int32 iID = Convert.ToInt32(Common.Decrypt(Request.QueryString["id"], Session.SessionID)); Discount clsDiscount = new Discount(); DiscountDetails clsDetails = clsDiscount.Details(iID); clsDiscount.CommitAndDispose(); lblDiscountID.Text = Convert.ToString(clsDetails.DiscountID); txtDiscountCode.Text = clsDetails.DiscountCode; txtDiscountType.Text = clsDetails.DiscountType; txtDiscountPrice.Text = clsDetails.DiscountPrice.ToString(); chkInPercent.Checked = Convert.ToBoolean(clsDetails.InPercent); }
private void SaveRecord() { Discount clsDiscount = new Discount(); DiscountDetails clsDetails = new DiscountDetails(); clsDetails.DiscountID = Convert.ToInt16(lblDiscountID.Text); clsDetails.DiscountCode = txtDiscountCode.Text; clsDetails.DiscountType = txtDiscountType.Text; clsDetails.DiscountPrice = Convert.ToDecimal(txtDiscountPrice.Text); clsDetails.InPercent = Convert.ToBoolean(chkInPercent.Checked); clsDiscount.Update(clsDetails); clsDiscount.CommitAndDispose(); }
private Int32 SaveRecord() { Discount clsDiscount = new Discount(); DiscountDetails clsDetails = new DiscountDetails(); clsDetails.DiscountCode = txtDiscountCode.Text; clsDetails.DiscountType = txtDiscountType.Text; clsDetails.DiscountPrice = Convert.ToDecimal(txtDiscountPrice.Text); clsDetails.InPercent = Convert.ToBoolean(chkInPercent.Checked); int id = clsDiscount.Insert(clsDetails); clsDiscount.CommitAndDispose(); return(id); }
public async Task <IActionResult> CreateReservationForCarOnDiscount(DiscountDetails paramss) { if (ModelState.IsValid) { var temp = await carService.CreateReservationForCarOnDiscount(paramss); if (temp != null) { return(Ok(temp)); } else { return(BadRequest(new { Message = "Something went wrong. Please, try again later." })); } } else { return(BadRequest(new { Message = "Invalid parameters supplied." })); } }
public void ClearAllDiscounts() { DiscountDetails.Clear(); }
public void AddAdjustment(DiscountDetail discount) { DiscountDetails.Add(discount); }
/// <summary> /// Allows you to populate the current line item object using a LineItemDTO instance /// </summary> /// <param name="dto">An instance of the line item from the REST API</param> public void FromDto(LineItemDTO dto) { if (dto == null) { return; } Id = dto.Id; StoreId = dto.StoreId; LastUpdatedUtc = dto.LastUpdatedUtc; BasePricePerItem = dto.BasePricePerItem; LineTotal = dto.LineTotal; AdjustedPricePerItem = dto.AdjustedPricePerItem; IsUserSuppliedPrice = dto.IsUserSuppliedPrice; IsBundle = dto.IsBundle; IsGiftCard = dto.IsGiftCard; PromotionIds = dto.PromotionIds; FreeQuantity = dto.FreeQuantity; DiscountDetails.Clear(); if (dto.DiscountDetails != null) { foreach (var detail in dto.DiscountDetails) { var d = new DiscountDetail(); d.FromDto(detail); DiscountDetails.Add(d); } } OrderBvin = dto.OrderBvin ?? string.Empty; ProductId = dto.ProductId ?? string.Empty; VariantId = dto.VariantId ?? string.Empty; ProductName = dto.ProductName ?? string.Empty; ProductSku = dto.ProductSku ?? string.Empty; ProductShortDescription = dto.ProductShortDescription ?? string.Empty; Quantity = dto.Quantity; QuantityReturned = dto.QuantityReturned; QuantityShipped = dto.QuantityShipped; ShippingPortion = dto.ShippingPortion; TaxRate = dto.TaxRate; TaxPortion = dto.TaxPortion; StatusCode = dto.StatusCode ?? string.Empty; StatusName = dto.StatusName ?? string.Empty; SelectionData.Clear(); if (dto.SelectionData != null) { foreach (var op in dto.SelectionData) { var o = new OptionSelection(); o.FromDto(op); SelectionData.OptionSelectionList.Add(o); } } IsNonShipping = dto.IsNonShipping; TaxSchedule = dto.TaxSchedule; ProductShippingHeight = dto.ProductShippingHeight; ProductShippingLength = dto.ProductShippingLength; ProductShippingWeight = dto.ProductShippingWeight; ProductShippingWidth = dto.ProductShippingWidth; CustomProperties.Clear(); if (dto.CustomProperties != null) { foreach (var cpd in dto.CustomProperties) { var prop = new CustomProperty(); prop.FromDto(cpd); CustomProperties.Add(prop); } } ShipFromAddress.FromDto(dto.ShipFromAddress); ShipFromMode = (ShippingMode)(int)dto.ShipFromMode; ShipFromNotificationId = dto.ShipFromNotificationId ?? string.Empty; ShipSeparately = dto.ShipSeparately; ExtraShipCharge = dto.ExtraShipCharge; ShippingCharge = (ShippingChargeType)(int)dto.ShippingCharge; }
public async Task <CarReservation> CreateReservationForCarOnDiscount(DiscountDetails paramss) { var enterprise = await repo2.GetOneEnterprise(paramss.EnterpriseId); var car = await repo.GetOneCar(paramss.EnterpriseId, paramss.CarId); var specialOfferss = await repo3.GetAllSpecialOffers(paramss.EnterpriseId); int numberOfDays = (paramss.DateTo - paramss.DateFrom).Days + 1; int price = numberOfDays * car.Price; CarReservation retValue = new CarReservation(); retValue.IsRated = false; retValue.Username = paramss.Username; retValue.NumberOfDays = numberOfDays; retValue.SelectedCar = car; retValue.SelectedEnterprise = enterprise; retValue.DateFrom = paramss.DateFrom; retValue.DateTo = paramss.DateTo; retValue.RentedDay = paramss.RentedDay; List <SpecialOffer> specialOffers = specialOfferss.OrderBy(i => i.NumberOfDays).ToList(); for (int i = 0; i < specialOffers.Count() - 2; i++) { if (numberOfDays == specialOffers[i].NumberOfDays) { retValue.RealizedPackage = specialOffers[i]; } for (int j = i + 1; j <= specialOffers.Count() - 1; j++) { if (numberOfDays > specialOffers[i].NumberOfDays && numberOfDays < specialOffers[j].NumberOfDays) { retValue.RealizedPackage = specialOffers[i]; } else if (numberOfDays == specialOffers[j].NumberOfDays) { retValue.RealizedPackage = specialOffers[j]; } else if (numberOfDays > specialOffers[i].NumberOfDays && numberOfDays >= specialOffers[j].NumberOfDays) { retValue.RealizedPackage = specialOffers[j]; } } } if (retValue.RealizedPackage != null) { price = price - ((price * retValue.RealizedPackage.Discount) / 100); retValue.Price = price - ((price * paramss.Percentage) / 100); } else { retValue.Price = price - ((price * paramss.Percentage) / 100); } return(retValue); }