public async Task <TMapTo> UpdateDiscountAsync <TMapTo>(Discounts discountToUpdate) where TMapTo : Discounts { try { var address = await this.GetDiscountByIdAsync(discountToUpdate.Id); var mappedDtoModel = _mapper.Map <Discounts, DiscountsDTO>(discountToUpdate, address); var updatedModel = _discountsContext.Discounts.Update(mappedDtoModel); if (updatedModel is null) { throw new Exception( $"Can not update entity {typeof(DiscountsDTO)} using data from object parameter {nameof(discountToUpdate)}"); } await _discountsContext.SaveChangesAsync(); return(_mapper.Map <TMapTo>(updatedModel)); } catch (Exception ex) { throw new Exception( "Some error occured while updating customer. Updated changes won't be applied", ex); } }
public ActionResult Get() { var userid = ObtenerIDUser(); var qrCodes = context.QrCode.Where(x => x.IdUser == userid && (x.Consumed == false || x.Valued == false)).ToList(); //return Ok(new { results = qrCodes }); var ListQR = new List <ModelQrDiscount>(); var obj = new ModelQrDiscount(); var objD = new Discounts(); var objC = new Commerce(); foreach (QrCode Cont in qrCodes) { obj = new ModelQrDiscount(); objD = context.Discounts.FirstOrDefault(x => x.Id == Cont.IdDiscount); objC = context.Commerce.FirstOrDefault(x => x.Id == (context.CommerceDiscounts.FirstOrDefault(y => y.DiscountsID == objD.Id).CommerceID)); obj.IdDiscount = Cont.IdDiscount; obj.IdCommerce = Cont.IdCommerce; obj.qrId = Cont.Id; //obj.IdCommerce = objC.Id; obj.CommerceName = context.BusinessModels.FirstOrDefault(x => x.Id == context.BussinessCommerce.FirstOrDefault(y => y.Commerce == Cont.IdCommerce).Bussines).Name; obj.CommerceAddres = objC.Address; obj.Discount_value = objD.Discount_value; obj.Discount_Type = objD.Discount_Type; obj.InterestDescription = context.Interests.FirstOrDefault(x => x.Id == context.DiscountsInterests.FirstOrDefault(y => y.DiscountsID == objD.Id).InterestsId).Name;; obj.CommerceImage = context.BusinessModels.FirstOrDefault(x => x.Id == context.BussinessCommerce.FirstOrDefault(y => y.Commerce == Cont.IdCommerce).Bussines).Image; obj.Consumed = Cont.Consumed; ListQR.Add(obj); } return(Ok(new { results = ListQR })); //return context.Commerce.ToList(); }
public virtual void ApplyDiscount(Discount discount) { // Apply the discount PriceEachOverride = discount.Apply(this); // Add the discount to this product's list. Discounts.Add(discount); }
public async Task <TMapTo> CreateDiscountAsync <TMapTo>(Discounts discountCreate) where TMapTo : Discounts { try { var mappedDtoModel = _mapper.Map <Discounts, DiscountsDTO>(discountCreate); var createdEntity = await _discountsContext.Discounts.AddAsync(mappedDtoModel); if (createdEntity is null) { throw new Exception( $"Can not create entity {typeof(DiscountsDTO)} from parameter {nameof(discountCreate)}"); } await _discountsContext.SaveChangesAsync(); var mappedCreatedEntity = _mapper.Map <DiscountsDTO, TMapTo>(createdEntity); return(mappedCreatedEntity); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Корректная инициализация сущностей CouponDiscount и PercentDiscount /// </summary> /// <param name="discountType"></param> /// <returns></returns> private static DiscountBase ReadDiscount(Discounts discountType) { var isCorrectInitialization = false; while (!isCorrectInitialization) { try { switch (discountType) { case Discounts.Coupon: { WriteLine("Введите размер скидки по купону: "); return(new CouponDiscount(ReadDouble())); } case Discounts.Percent: { WriteLine("Введите размер скидки в %: "); return(new PercentDiscount(ReadDouble())); } } } catch (Exception e) { WriteLine(e.Message + "\nВведите заново!\n"); } } return(null); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is V1PaymentItemization other && ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) && ((Quantity == null && other.Quantity == null) || (Quantity?.Equals(other.Quantity) == true)) && ((ItemizationType == null && other.ItemizationType == null) || (ItemizationType?.Equals(other.ItemizationType) == true)) && ((ItemDetail == null && other.ItemDetail == null) || (ItemDetail?.Equals(other.ItemDetail) == true)) && ((Notes == null && other.Notes == null) || (Notes?.Equals(other.Notes) == true)) && ((ItemVariationName == null && other.ItemVariationName == null) || (ItemVariationName?.Equals(other.ItemVariationName) == true)) && ((TotalMoney == null && other.TotalMoney == null) || (TotalMoney?.Equals(other.TotalMoney) == true)) && ((SingleQuantityMoney == null && other.SingleQuantityMoney == null) || (SingleQuantityMoney?.Equals(other.SingleQuantityMoney) == true)) && ((GrossSalesMoney == null && other.GrossSalesMoney == null) || (GrossSalesMoney?.Equals(other.GrossSalesMoney) == true)) && ((DiscountMoney == null && other.DiscountMoney == null) || (DiscountMoney?.Equals(other.DiscountMoney) == true)) && ((NetSalesMoney == null && other.NetSalesMoney == null) || (NetSalesMoney?.Equals(other.NetSalesMoney) == true)) && ((Taxes == null && other.Taxes == null) || (Taxes?.Equals(other.Taxes) == true)) && ((Discounts == null && other.Discounts == null) || (Discounts?.Equals(other.Discounts) == true)) && ((Modifiers == null && other.Modifiers == null) || (Modifiers?.Equals(other.Modifiers) == true))); }
public virtual Shipment ToModel(Shipment shipment) { if (shipment == null) { throw new ArgumentNullException(nameof(shipment)); } shipment.Id = Id; shipment.CreatedBy = CreatedBy; shipment.CreatedDate = CreatedDate; shipment.ModifiedBy = ModifiedBy; shipment.ModifiedDate = ModifiedDate; shipment.Fee = Fee; shipment.FeeWithTax = FeeWithTax; shipment.FulfillmentCenterId = FulfillmentCenterId; shipment.ShipmentMethodCode = ShipmentMethodCode; shipment.Total = Total; shipment.TotalWithTax = TotalWithTax; shipment.TaxTotal = TaxTotal; shipment.Price = Price; shipment.PriceWithTax = PriceWithTax; shipment.DiscountAmount = DiscountAmount; shipment.DiscountAmountWithTax = DiscountAmountWithTax; shipment.TaxPercentRate = TaxPercentRate; shipment.Currency = Currency; shipment.WeightUnit = WeightUnit; shipment.Weight = WeightValue; shipment.Height = DimensionHeight; shipment.Length = DimensionLength; shipment.WeightUnit = DimensionUnit; shipment.Weight = DimensionWidth; shipment.TaxType = TaxType; shipment.ShipmentMethodOption = ShipmentMethodOption; //TODO //shipment.TaxIncluded = TaxIncluded; //shipment.MeasureUnit = if (!Addresses.IsNullOrEmpty()) { shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } if (!Discounts.IsNullOrEmpty()) { shipment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); } if (!Items.IsNullOrEmpty()) { shipment.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList(); } if (!TaxDetails.IsNullOrEmpty()) { shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); } return(shipment); }
/// <summary> /// Accepts the changes. /// </summary> public override void AcceptChanges() { if (_Parent == null) { throw new NoNullAllowedException("Parent"); } if (_Parent.ObjectState == MetaObjectState.Added) { throw new MetaException("Must save parent object"); } if (ObjectState != MetaObjectState.Deleted) { this.OrderGroupId = _Parent.OrderGroupId; this.OrderFormId = _Parent.OrderFormId; } using (TransactionScope scope = new TransactionScope()) { base.AcceptChanges(); if (this.ObjectState != MetaObjectState.Deleted) { Discounts.AcceptChanges(); } scope.Complete(); } }
public async Task <IActionResult> PutDiscounts(int id, Discounts discounts) { if (id != discounts.Id) { return(BadRequest()); } _context.Entry(discounts).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DiscountsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public override OrderOperation ToModel(OrderOperation operation) { var shipment = operation as Shipment; if (shipment == null) { throw new ArgumentException(@"operation argument must be of type Shipment", nameof(operation)); } if (!Addresses.IsNullOrEmpty()) { shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } shipment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); shipment.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList(); shipment.InPayments = InPayments.Select(x => x.ToModel(AbstractTypeFactory <PaymentIn> .TryCreateInstance())).OfType <PaymentIn>().ToList(); shipment.Packages = Packages.Select(x => x.ToModel(AbstractTypeFactory <ShipmentPackage> .TryCreateInstance())).ToList(); shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); base.ToModel(shipment); operation.Sum = shipment.TotalWithTax; return(shipment); }
public virtual Shipment ToModel(Shipment shipment) { if (shipment == null) { throw new ArgumentNullException(nameof(shipment)); } shipment.InjectFrom(this); // workaround for mis-spelling shipment.FulfillmentCenterId = FulfilmentCenterId; if (!Addresses.IsNullOrEmpty()) { shipment.DeliveryAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } if (!Discounts.IsNullOrEmpty()) { shipment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); } if (!Items.IsNullOrEmpty()) { shipment.Items = Items.Select(x => x.ToModel(AbstractTypeFactory <ShipmentItem> .TryCreateInstance())).ToList(); } if (!TaxDetails.IsNullOrEmpty()) { shipment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); } return(shipment); }
private void EditDiscount() { DiscountRepository discrep = new DiscountRepository(); Discounts disc = (Discounts)binSourceBusStation.Current; List <BusinessTickets> busTicketsD = DeleteTicketsANDFlights(disc); discrep.Delete(disc); Discounts newdisc = new Discounts(); newdisc.DiscountName = disc.DiscountName; newdisc.Size = disc.Size; newdisc.Information = disc.Information; discrep.Create(newdisc); if (busTicketsD.Count > 0) { BusinessTickets bustick = new BusinessTickets(); BusinessTicketsRepository bustickrep = new BusinessTicketsRepository(); for (int i = 0; i < busTicketsD.Count; i++) { bustick.ReleaseDate = busTicketsD[i].ReleaseDate; bustick.FlightId = busTicketsD[i].FlightId; bustick.SeatId = busTicketsD[i].SeatId; bustick.DiscountId = newdisc.DiscountId; bustick.Sold = busTicketsD[i].Sold; bustick.Reserve = busTicketsD[i].Reserve; bustick.Canceled = busTicketsD[i].Canceled; bustickrep.Create(bustick); } } MessageBox.Show("Discount Edit"); }
public double CheckPositionDiscountTest(double price, Discounts type, double value) { var checkPosition = new CheckPosition(DiscountFactory.GetDiscount(type, value), new Product(price)); return(checkPosition.CheckPositionDiscount); }
public async Task <ActionResult <Discounts> > PostDiscounts(Discounts discounts) { _context.Discounts.Add(discounts); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDiscounts", new { id = discounts.Id }, discounts)); }
public virtual void Patch(ShipmentEntity target) { if (target == null) { throw new ArgumentNullException(nameof(target)); } target.Fee = Fee; target.FeeWithTax = FeeWithTax; target.FulfillmentCenterId = FulfillmentCenterId; target.FulfillmentCenterName = FulfillmentCenterName; target.ShipmentMethodCode = ShipmentMethodCode; target.Total = Total; target.TotalWithTax = TotalWithTax; target.TaxTotal = TaxTotal; target.Price = Price; target.PriceWithTax = PriceWithTax; target.DiscountAmount = DiscountAmount; target.DiscountAmountWithTax = DiscountAmountWithTax; target.TaxPercentRate = TaxPercentRate; target.TaxIncluded = TaxIncluded; target.Currency = Currency; target.WeightUnit = WeightUnit; target.WeightValue = WeightValue; target.DimensionHeight = DimensionHeight; target.DimensionLength = DimensionLength; target.DimensionUnit = DimensionUnit; target.DimensionWidth = DimensionWidth; target.TaxType = TaxType; target.ShipmentMethodOption = ShipmentMethodOption; if (!Addresses.IsNullCollection()) { Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress)); } if (!Items.IsNullCollection()) { Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem)); } if (!TaxDetails.IsNullCollection()) { var taxDetailComparer = AbstractTypeFactory <TaxDetailEntityComparer> .TryCreateInstance(); TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail)); } if (!Discounts.IsNullCollection()) { var discountComparer = AbstractTypeFactory <DiscountEntityComparer> .TryCreateInstance(); Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount)); } if (!DynamicPropertyObjectValues.IsNullCollection()) { DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues)); } }
public void ParseCommand(string command) { bool status = int.TryParse(command, out int commandNumber); if (!status) { return; } if (!Enum.IsDefined(typeof(Commands), commandNumber)) { commandNumber = (int)Commands.buyTicket; } switch ((Commands)commandNumber) { case Commands.exit: Environment.Exit(0); break; case Commands.buyTicket: string typeToParse = UserInterface.AskForTicketType(); TicketTypes type = ParseType(typeToParse); Ticket ticket = TicketFactory.CreateTicket(type); string discountToParse = UserInterface.AskForDiscount(); Discounts desiredDiscount = ParseDiscount(discountToParse); var discountDecorator = new DiscountDecorator(ticket, desiredDiscount); Logger.LogTicket(discountDecorator); UserInterface.PrintingPrompt(); break; } }
public void AddDiscount(string c, string pdf) { Discount d = new Discount(c, pdf); Discounts.Add(d); Company.Discounts.Add(d); }
public override void Patch(OperationEntity operation) { base.Patch(operation); var target = operation as PaymentInEntity; if (target == null) { throw new ArgumentException(@"operation argument must be of type PaymentInEntity", nameof(operation)); } target.Amount = Amount; target.Price = Price; target.PriceWithTax = PriceWithTax; target.DiscountAmount = DiscountAmount; target.DiscountAmountWithTax = DiscountAmountWithTax; target.TaxType = TaxType; target.TaxPercentRate = TaxPercentRate; target.TaxTotal = TaxTotal; target.Total = Total; target.TotalWithTax = TotalWithTax; target.CustomerId = CustomerId; target.CustomerName = CustomerName; target.OrganizationId = OrganizationId; target.OrganizationName = OrganizationName; target.GatewayCode = GatewayCode; target.Purpose = Purpose; target.OuterId = OuterId; target.Status = Status; target.AuthorizedDate = AuthorizedDate; target.CapturedDate = CapturedDate; target.VoidedDate = VoidedDate; target.IsCancelled = IsCancelled; target.CancelledDate = CancelledDate; target.CancelReason = CancelReason; target.Sum = Sum; if (!Addresses.IsNullCollection()) { Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress)); } if (!TaxDetails.IsNullCollection()) { var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name); TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail)); } if (!Discounts.IsNullCollection()) { var discountComparer = AnonymousComparer.Create((DiscountEntity x) => x.PromotionId); Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount)); } if (!Transactions.IsNullCollection()) { Transactions.Patch(target.Transactions, (sourceTran, targetTran) => sourceTran.Patch(targetTran)); } }
public void ApplyRewards(IEnumerable <PromotionReward> rewards) { var productRewards = rewards.Where(r => r.RewardType == PromotionRewardType.CatalogItemAmountReward && (r.ProductId.IsNullOrEmpty() || r.ProductId.EqualsInvariant(Id))); if (productRewards == null) { return; } Discounts.Clear(); Price.DiscountAmount = new Money(Math.Max(0, (Price.ListPrice - Price.SalePrice).Amount), Currency); foreach (var reward in productRewards) { //Initialize tier price discount amount by default values var discount = reward.ToDiscountModel(Price.SalePrice); foreach (var tierPrice in Price.TierPrices) { tierPrice.DiscountAmount = new Money(Math.Max(0, (Price.ListPrice - tierPrice.Price).Amount), Currency); } if (reward.IsValid) { Discounts.Add(discount); Price.DiscountAmount += discount.Amount; //apply discount to tier prices foreach (var tierPrice in Price.TierPrices) { discount = reward.ToDiscountModel(tierPrice.Price); tierPrice.DiscountAmount += discount.Amount; } } } }
public void Create(Discounts model) { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "INSERT INTO Discounts VALUES (@did, @pid, @discount, @start, @end"; connection.Open(); var transaction = connection.BeginTransaction(/*default:readuncommited*/); //excute commands try { transaction.Commit(); } catch (SqlException e) { transaction.Rollback(); } SqlCommand command = new SqlCommand(sql, connection); command = AddWithAllDiscountValue(model); connection.Open(); command.ExecuteReader(); connection.Close(); }
/// <summary> /// Find Discount /// </summary> /// <param name="discountId"></param> /// <returns></returns> public Discounts FindById(string discountId) { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "SELECT * FROM Discounts WHERE DiscountID = @did"; SqlCommand command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@id", discountId); connection.Open(); var reader = command.ExecuteReader(CommandBehavior.CloseConnection); var discount = new Discounts(); while (reader.Read()) { discount.DiscountID = Convert.ToInt32(reader.GetValue(reader.GetOrdinal("DiscountID"))); discount.ProductID = Convert.ToInt32(reader.GetValue(reader.GetOrdinal("ProductID"))); discount.Discount = Convert.ToDouble(reader.GetValue(reader.GetOrdinal("Discount"))); discount.StartTime = Convert.ToDateTime(reader.GetValue(reader.GetOrdinal("StartTime"))); discount.EndTime = Convert.ToDateTime(reader.GetValue(reader.GetOrdinal("EndTime"))); } reader.Close(); connection.Close(); return(discount); }
public DiscountsMod(Discounts d) { this.DiscountID = d.DiscountID; this.UserID = d.UserID.UserID; this.GoodID = d.GoodID.GoodID; this.percent = d.percents; }
public void ApplyRewards(IEnumerable <PromotionReward> rewards) { var productRewards = rewards.Where(r => r.RewardType == PromotionRewardType.CatalogItemAmountReward && (r.ProductId.IsNullOrEmpty() || r.ProductId.EqualsInvariant(Id))); if (productRewards == null) { return; } Discounts.Clear(); foreach (var reward in productRewards) { //Apply discount to main price var discount = reward.ToDiscountModel(Price.SalePrice); if (reward.IsValid) { Discounts.Add(discount); Price.ActiveDiscount = discount; //apply discount to tier prices foreach (var tierPrice in Price.TierPrices) { discount = reward.ToDiscountModel(tierPrice.Price); tierPrice.ActiveDiscount = discount; } } } }
public async Task <int> SaveDiscountsAsync(Discounts discount) { _ = _dbContext.Discounts.Add(discount); await _dbContext.SaveChangesAsync(); return(discount.Id); }
public static DiscountsModel EntityToModel(this Discounts entity, bool virtualActive = false) { try { DiscountsModel model = new DiscountsModel() { Description = entity.Description, Name = entity.Name, EndingDate = entity.EndingDate, Rate = entity.Rate, StartingDate = entity.StartingDate, IsActive = entity.IsActive, Id = entity.Id }; if (virtualActive) { model.RoomSales = entity.RoomSales; } return(model); } catch (Exception) { return(new DiscountsModel()); } }
public override object Clone() { var result = base.Clone() as Shipment; result.Price = Price?.Clone() as Money; result.PriceWithTax = PriceWithTax?.Clone() as Money; result.DiscountAmount = DiscountAmount?.Clone() as Money; result.DiscountAmountWithTax = DiscountAmountWithTax?.Clone() as Money; result.Total = Total?.Clone() as Money; result.TotalWithTax = TotalWithTax?.Clone() as Money; result.TaxTotal = TaxTotal?.Clone() as Money; if (Discounts != null) { result.Discounts = new List <Discount>(Discounts.Select(x => x.Clone() as Discount)); } if (TaxDetails != null) { result.TaxDetails = new List <TaxDetail>(TaxDetails.Select(x => x.Clone() as TaxDetail)); } if (Items != null) { result.Items = new List <CartShipmentItem>(Items.Select(x => x.Clone() as CartShipmentItem)); } if (ValidationErrors != null) { result.ValidationErrors = new List <ValidationError>(ValidationErrors.Select(x => x.Clone() as ValidationError)); } return(result); }
private void AplyDiscount(int bicycleCount) { var discount = Discounts.ApplyDiscount(bicycleCount); TotalPrice = TotalPrice - TotalPrice * discount.Percentage; Discounts = discount; }
public virtual Payment ToModel(Payment payment) { if (payment == null) { throw new ArgumentNullException(nameof(payment)); } payment.InjectFrom(this); if (!TaxDetails.IsNullOrEmpty()) { payment.TaxDetails = TaxDetails.Select(x => x.ToModel(AbstractTypeFactory <TaxDetail> .TryCreateInstance())).ToList(); } if (!Discounts.IsNullOrEmpty()) { payment.Discounts = Discounts.Select(x => x.ToModel(AbstractTypeFactory <Discount> .TryCreateInstance())).ToList(); } if (!Addresses.IsNullOrEmpty()) { payment.BillingAddress = Addresses.First().ToModel(AbstractTypeFactory <Address> .TryCreateInstance()); } return(payment); }
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 double calculateTotal() { // ... total = Discounts.applyRegionalDiscounts(total, user.getCountry()); total = Discounts.applyCoupons(total); // ... }
public Discount GetByCode(string code) { var table = new Discounts(); var result = table.All(where: "WHERE Code = @0", limit: 1, args: code); return new Discount(result); }
public IEnumerable<Discount> GetAll() { var table = new Discounts(); var result = table.All(); return result.Select(row => new Discount(row)); }
public void Save(IDiscountDefinition discount) { throw new NotSupportedException("Massive insert does not like SQL CE"); // but it looks like this var table = new Discounts(); table.Insert(new { discount.Code, discount.ExpirationDate, discount.ValidationScript, discount.ValidationScriptType, }); }
public void CreateDiscounts() { _discounts = new Discounts(); }