public void When_Applies_Discount_To_Products_And_There_Are_Discounts_For_This_Products_Then_Returns_Correct_List_Of_Products_With_Discounts() { // Arrange var productCategory = new ProductCategory("", ""); productCategory.AddProduct(Product); Product.SetProductCategory(productCategory); var discountCategory = new DiscountCategory(productCategory, ProductCategoryDiscount); ProductCategoryDiscount.AddProductCategory(new[] { discountCategory }); var expected = new List <ApplyDiscountsToProductsResult> { new ApplyDiscountsToProductsResult(Product, ProductCategoryDiscount) }; // Act var result = sut.ApplyDiscountsToProducts(new List <Product> { Product }, new List <ProductCategoryDiscount> { ProductCategoryDiscount }); // Assert result.Should().NotBeNull(); result.Should().BeEquivalentTo(expected); }
private void CustomDialogClosed(object sender, RoutedEventArgs e) { categoriaElegida = (DiscountCategory)customDialog.SelectedItem; if (categoriaElegida != null) { CategoriaButton.DataContext = listaCategorias.FirstOrDefault(category => category.Name == categoriaElegida.Name); } }
public static double DiscountCategoryToRate(DiscountCategory category) { switch (Enum.GetName(typeof(DiscountCategory), category)) { case "A": return(1); case "B": return(0.9); case "C": return(0.7); default: return(1); } }
public Promotion( string strDescription, int nPromotionTypeID, bool fItemDiscount, decimal mMinimumAmount, DateTime dtValidStart, DateTime dtValidEnd, double dDiscountPercent, double dDiscountValue, DiscountCategory discountCategory, Employee approvedStatus ) { this._strDescription = strDescription; this._nPromotionTypeID = nPromotionTypeID; this._fItemDiscount = fItemDiscount; this._mMinimumAmount = mMinimumAmount; this._dtValidStart = dtValidStart; this._dtValidEnd = dtValidEnd; this._dDiscountPercent = dDiscountPercent; this._dDiscountValue = dDiscountValue; this._discountCategory = discountCategory; this._approvedStatus = approvedStatus; }
public static ProductDiscount GetDiscount(DiscountCategory discountCategory, Product product) { if (discountCategory == DiscountCategory.EMPLOYEE_DISCOUNT) { return(new DiscountForEmployee(product)); } else if (discountCategory == DiscountCategory.SENIOR_CITIZEN_DISCOUNT) { return(new DiscountForSeniorCitizen(product)); } else if (discountCategory == DiscountCategory.CHIPS_CATEGORY_DISCOUNT) { return(new DiscountForChips(product)); } return(null); }
private (List <Product>, List <ProductCategoryDiscount>) PrepareProductsWithDiscounts() { var product1 = new Product("Test", "Test", 50, "Test", "Test", true, "", "") { Id = 1 }; var product2 = new Product("Test2", "Test2", 40, "Test2", "Test2", true, "", "") { Id = 2 }; var product3 = new Product("Test3", "Test3", 30, "Test3", "Test3", true, "", "") { Id = 3 }; var product4 = new Product("Test4", "Test3", 30, "Test3", "Test3", true, "", "") { Id = 4 }; var category1 = new ProductCategory("Test1", "Test1"); var category2 = new ProductCategory("Test2", "Test2"); product1.SetProductCategory(category1); product2.SetProductCategory(category1); product3.SetProductCategory(category2); var productCategoryDiscount1 = new ProductCategoryDiscount("Test1", "Test1", "Test1", "Test1", 30, DateTime.Now.AddDays(-10), DateTime.Now.AddDays(10)); var productCategoryDiscount2 = new ProductCategoryDiscount("Test2", "Test2", "Test2", "Test2", 30, DateTime.Now.AddDays(-10), DateTime.Now.AddDays(10)); var discountCategory1 = new DiscountCategory(category1, productCategoryDiscount1); var discountCategory2 = new DiscountCategory(category2, productCategoryDiscount2); productCategoryDiscount1.AddProductCategory(new[] { discountCategory1 }); productCategoryDiscount2.AddProductCategory(new[] { discountCategory2 }); var products = new List <Product> { product1, product2, product3, product4 }; var discounts = new List <ProductCategoryDiscount> { productCategoryDiscount1, productCategoryDiscount2 }; return(products, discounts); }
/// <summary> /// set category for same isbn product /// </summary> /// <param name="isbn"></param> /// <param name="category"></param> public void SetCategory(string isbn, DiscountCategory category) { discountCategories[isbn] = category; }
public LoyaltyStatus( string strDescription, DiscountCategory discountCategory ) { this._strDescription = strDescription; this._discountCategory = discountCategory; }
private async Task SaveDiscount(DeserializeBranchItem branchItem, Discount discountDbData) { string logoFileName; if (!string.IsNullOrEmpty(branchItem.Icon)) { logoFileName = branchItem.Id + PostfixLogoFileName; await SaveImage(logoFileName, branchItem.Icon); } else { logoFileName = null; } _database.BeginTransaction(); if (discountDbData != null) { _database.Table <WebAddress>().Delete(i => i.DiscountId == discountDbData.Id); _database.Table <DiscountCategory>().Delete(i => i.DiscountId == discountDbData.Id); _database.Table <DiscountsStrings>() .Where(i => i.OwnerId == discountDbData.Id && (i.Appointment == StrAppointmentTitle || i.Appointment == StrAppointmentDescription)) .Select(i => i.LangStringId).ForEach(i => _database.Table <LangString>().Delete(j => j.Id == i)); _database.Table <DiscountsStrings>().Delete(i => i.OwnerId == discountDbData.Id && (i.Appointment == StrAppointmentTitle || i.Appointment == StrAppointmentDescription)); var images = _database.Table <GalleryImage>().Where(i => i.DiscountId == discountDbData.Id) .Select(i => i.FileName); DeleteGallery(images); _database.Table <GalleryImage>().Delete(i => i.DiscountId == discountDbData.Id); discountDbData.DocumentId = branchItem.Id; discountDbData.LogoFileName = logoFileName; discountDbData.ImageFileName = null; discountDbData.PercentValue = branchItem.Discounts.FirstOrDefault()?.Name?.FirstOrDefault()?.LocText; discountDbData.DiscountType = branchItem.Discounts.FirstOrDefault()?.DiscountType; discountDbData.Modified = branchItem.Modified ?? DateTime.UtcNow; _database.Update(discountDbData); } else { discountDbData = new Discount { DocumentId = branchItem.Id, LogoFileName = logoFileName, ImageFileName = null, PercentValue = branchItem.Discounts.FirstOrDefault()?.Name?.FirstOrDefault()?.LocText, DiscountType = branchItem.Discounts.FirstOrDefault()?.DiscountType, Modified = branchItem.Modified ?? DateTime.UtcNow }; _database.Insert(discountDbData); } #region save children if (branchItem.Name != null) { foreach (var name in branchItem.Name) { var langStringRec = new LangString { LanguageCode = name.Lan.ToUpper(), Text = name.LocText }; _database.Insert(langStringRec); var discountsStringsRec = new DiscountsStrings { Appointment = StrAppointmentTitle, OwnerId = discountDbData.Id, LangStringId = langStringRec.Id }; _database.Insert(discountsStringsRec); } } if (branchItem.Description != null) { foreach (var name in branchItem.Description) { var langStringRec = new LangString { LanguageCode = name.Lan.ToUpper(), Text = name.LocText }; _database.Insert(langStringRec); var discountsStringsRec = new DiscountsStrings { Appointment = StrAppointmentDescription, OwnerId = discountDbData.Id, LangStringId = langStringRec.Id }; _database.Insert(discountsStringsRec); } } if (branchItem.CategoryIds != null) { foreach (var category in branchItem.CategoryIds) { var categorieRec = new DiscountCategory { DiscountId = discountDbData.Id, CategoryId = category }; _database.Insert(categorieRec); } } if (branchItem.WebAddresses != null) { foreach (var webAddress in branchItem.WebAddresses) { var webAddressRec = new WebAddress { DiscountId = discountDbData.Id, Category = webAddress.Category, Url = webAddress.Url }; _database.Insert(webAddressRec); } } #endregion _database.Commit(); }
public JobPosition( string strDescription, DiscountCategory discountCategory ) { this._strDescription = strDescription; this._discountCategory = discountCategory; }
public List <DiscountDTO> DescuentosCercanos(double latitud, double longitud, string texto, int rango, DiscountCategory category, string medida) { AutoMapperConfiguration.Initialize(); uow = new UnitOfWork(); var pos = new GeoZone { Latitude = latitud, Longitude = longitud }; var lista = uow.Discounts.Consulta(d => d.ProductName.Contains(texto) && d.DiscountCategory.Name == category.Name) .Select(Mapper.Map <Discount, DiscountDTO>).ToList(); var listaDescuentos = DescuentosDentroDeRango(lista, pos, medida, rango); return(listaDescuentos); }