private void populateAssignedPromotion() { DropDownLMinuteNo.Items.Clear(); DropDownLMinuteNo.Items.Add(new ListItem(" -- SELECT --", "-1")); DataTable dataTable = null; try { PromotionManager promotionManager = new PromotionManager(); dataTable = promotionManager.getUnassignedPromotion(); if (dataTable != null && dataTable.Rows.Count > 0) { // PROCESSOR DropDownLMinuteNo.DataSource = dataTable; DropDownLMinuteNo.DataValueField = "Minute_No"; DropDownLMinuteNo.DataTextField = "promotionDetial"; DropDownLMinuteNo.DataBind(); } else { clearMsgPanel(); msgPanel.Visible = true; InfoDIV.Visible = true; lblInformationMsg.Text = "Vacancy is opened for all promotion in the database, please first register new promoted employee and come back for Promotion assignment"; AssignPromotionPanel.Visible = false; } } //CATCH ANY OTHER EXCEPTION, dont let user see any kind of unexpected error catch (Exception ex) { //Write this exception to file for investigation of the issue later. LoggerManager.LogError(ex.ToString(), logger); } }
public void ApplyNoPromotion() { Order order = new Order(1, new List <Product>() { new Product("A"), new Product("A"), new Product("B") }); Assert.AreEqual(130, PromotionManager.GetFinalPrice(order)); }
public override void Dispose() { if (_promoManager != null) { _promoManager.Dispose(); _promoManager = null; } base.Dispose(); }
public void ApplySinglePromotionOnProductCandD() { Order order = new Order(1, new List <Product>() { new Product("C"), new Product("D") }); Assert.AreEqual(30, PromotionManager.GetFinalPrice(order)); }
public void ApplyMoreThanOnePromotionsOnAllProducts() { Order order = new Order(1, new List <Product>() { new Product("A"), new Product("A"), new Product("A"), new Product("B"), new Product("B"), new Product("C"), new Product("D") }); Assert.AreEqual(205, PromotionManager.GetFinalPrice(order)); }
protected override void Dispose(bool disposing) { if (_promotionManager != null) { _promotionManager.Dispose(); _promotionManager = null; } base.Dispose(disposing); }
/// <summary> /// Loads the fresh. /// </summary> /// <returns></returns> private PromotionDto LoadFresh() { PromotionDto promo = PromotionManager.GetPromotionDto(PromotionId); // persist in session Session[_PromotionDtoEditSessionKey] = promo; return(promo); }
public void TestEditPromotion() { //Arrange IPromotionManager promotionManager = new PromotionManager(_promotionAccessor); Promotion oldPromotion = new Promotion() { PromotionID = "TESTPROMO", PromotionTypeID = "Percent", Discount = 0.95M, Description = "Test Description", StartDate = DateTime.Today, EndDate = DateTime.Today.AddDays(1) }; oldPromotion.Products.Add(new Product() { ProductID = "1234567890123", ItemID = 10000, Brand = "Test Brand", Category = "Test Category", Name = "Test Product", Taxable = true, Type = "Test Type", Description = "Test product description", Price = 1.00M }); Promotion newPromotion = new Promotion() { PromotionID = "TESTPROMO", PromotionTypeID = "Flat Amount", Discount = 0.95M, Description = "Test Description2", StartDate = DateTime.Today.AddDays(1), EndDate = DateTime.Today.AddDays(2) }; newPromotion.Products.Add(new Product() { ProductID = "1234567890123", ItemID = 10000, Brand = "Test Brand", Category = "Test Category", Name = "Test Product", Taxable = true, Type = "Test Type", Description = "Test product description", Price = 1.00M }); bool expected = true; //Act bool actual = promotionManager.EditPromotion(oldPromotion, newPromotion); //Assert Assert.AreEqual(expected, actual); }
public ActionResult AdminDemoteAd(int adId) { var demo = PromotionManager.RemovePromoteAd(adId); demo.PromoDuration = PromotionStaticInfo.PromotionDuration.DurationRange; demo.UrgentAdPrice = PromotionStaticInfo.UrgentAdPaymentInfo.UrgentAdPrice.Price; demo.TopAdPrice = PromotionStaticInfo.TopAdPaymentInfo.TopAdPrice.Price; demo.FeaturedAdPrice = PromotionStaticInfo.FeaturedAdPaymentInfo.FeaturedAdPrice.Price; return(View("AdminFindPromoteAd", demo)); }
public ActionResult AdminPromoteUserAd(AdminPromoteClassifiedAd ad) { var promo = PromotionManager.PromoteAd(ad); promo.PromoDuration = PromotionStaticInfo.PromotionDuration.DurationRange; promo.UrgentAdPrice = PromotionStaticInfo.UrgentAdPaymentInfo.UrgentAdPrice.Price; promo.TopAdPrice = PromotionStaticInfo.TopAdPaymentInfo.TopAdPrice.Price; promo.FeaturedAdPrice = PromotionStaticInfo.FeaturedAdPaymentInfo.FeaturedAdPrice.Price; return(View("AdminFindPromoteAd", promo)); }
public ActionResult RemovePromo(string code) { if (!string.IsNullOrEmpty(code)) { var customer = HttpContext.GetCustomer(); PromotionManager.ClearPromotionUsages(customerId: customer.CustomerID, promotionCode: code, removeAutoAssigned: true); } return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public void GetPromotionsTestMethod() { using (ShimsContext.Create()) { IDoumentProvider doumentProvider = new DocumentManager(); PromotionManager productsManager = new PromotionManager(doumentProvider); var result = productsManager.GetPromotions(); Assert.IsNotNull(result); } }
protected void repeatPromotions_ItemCommand(Object sender, RepeaterCommandEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } PromotionManager.ClearPromotionUsages(ThisCustomer.CustomerID, e.CommandArgument.ToString(), true); UpdateCart(); BindPromotions(); }
static void Main(string[] args) { Console.WriteLine("Please select the Promotion Type : 1 -> Type A : 2 -> Type B"); var promoType = char.Parse(Console.ReadLine()); IPromotionRepository promotionRepository = new PromotionManager().GetPromotionInstance(promoType); IProductRepository productRepository = new ProductRepository(); IOrderRepository orderRepository = new OrderRepository(); OrderProcessing orderProcessing = new OrderProcessing(promotionRepository, productRepository, orderRepository); decimal totalOrderPrice = orderProcessing.StartProcessing(); Console.WriteLine("Total Amount for the Order={0}", totalOrderPrice); }
private void BuildResources() { var builder = new ContainerBuilder(); builder.RegisterType <CatalogSystemMapper>().As <ICatalogSystemMapper>().InstancePerLifetimeScope(); builder.Register(c => Indexer).InstancePerLifetimeScope(); builder.Register(c => this).As <IIndexLogger>().InstancePerLifetimeScope(); builder.RegisterType <IndexSystemMapper>().As <IIndexSystemMapper>().InstancePerLifetimeScope(); builder.RegisterType <MetaDataMapper>().As <IMetaDataMapper>().InstancePerLifetimeScope(); builder.RegisterType <PriceServiceMapper>().As <IPriceServiceMapper>().InstancePerLifetimeScope(); builder.RegisterType <AdAttributeHelper>().InstancePerLifetimeScope(); builder.RegisterType <Configuration.Configuration>().As <IConfiguration>().InstancePerLifetimeScope(); builder.Register(c => new ConfigurationOptions(Loader.LoadBaseConfiguration())).InstancePerLifetimeScope(); builder.RegisterType <AttributeConverter>().InstancePerLifetimeScope(); builder.RegisterType <ConfigurationWriter>().InstancePerLifetimeScope(); builder.RegisterType <OperationsWriter>().As <IOperationsWriter>(); builder.RegisterType <AppConfig>().As <IAppConfig>().InstancePerLifetimeScope(); builder.RegisterType <EntryConverter>().InstancePerLifetimeScope(); builder.Register(c => { var conf = c.Resolve <IAppConfig>(); return(conf.UseCodeAsKey ? (IKeyLookup) new CodeKeyLookup(c.Resolve <ConnectorHelper>()) : new IdKeyLookup()); }).InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(typeof(IIndexBuilder).Assembly).As <IIndexBuilder>().InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(typeof(IIndexImporter).Assembly).As <IIndexImporter>().InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(typeof(IIndexDeleter).Assembly).As <IIndexDeleter>().InstancePerLifetimeScope(); builder.RegisterType <FileSystem>().As <IFileSystem>().InstancePerLifetimeScope(); builder.RegisterType <FileHelper>().InstancePerLifetimeScope(); builder.RegisterType <ConnectorHelper>().InstancePerLifetimeScope(); builder.RegisterType <ConnectorMapper>().As <IConnectorMapper>().InstancePerLifetimeScope(); builder.Register( c => new PromotionDataTableMapper( PromotionManager.GetPromotionDto().PromotionLanguage, PromotionManager.GetPromotionDto().Promotion, CampaignManager.GetCampaignDto().Campaign)).InstancePerLifetimeScope(); builder.RegisterType <PromotionEntryCodeProvider>().InstancePerLifetimeScope(); builder.RegisterAssemblyTypes(typeof(IFormatRule).Assembly).As <IFormatRule>().InstancePerLifetimeScope(); builder.RegisterType <Formatter>().InstancePerLifetimeScope(); builder.RegisterType <ESalesIndexBuilder>().InstancePerLifetimeScope(); builder.RegisterType <UrlResolver>().As <IUrlResolver>(); builder.RegisterType <EntryAdditionalData>().As <IEntryAdditionalData>(); RegisterPlugins(builder); try { _container = builder.Build(); } catch (Exception e) { throw e.Unwrap(); } }
public void TestRetrieveAllPromotionTypes() { //Arrange IPromotionManager promotionManager = new PromotionManager(_promotionAccessor); int expectedCount = 1; //Act List <string> list = promotionManager.GetAllPromotionTypes(); //Assert Assert.AreEqual(expectedCount, list.Count); }
public ActionResult AdminFindPromoteAd(int?adId) { var promo = new AdminPromote() { Ad = adId != null?PromotionManager.GetPromoteAdById <AdminPromoteClassifiedAd>(adId.Value) : null, PromoDuration = PromotionStaticInfo.PromotionDuration.DurationRange, UrgentAdPrice = PromotionStaticInfo.UrgentAdPaymentInfo.UrgentAdPrice.Price, TopAdPrice = PromotionStaticInfo.TopAdPaymentInfo.TopAdPrice.Price, FeaturedAdPrice = PromotionStaticInfo.FeaturedAdPaymentInfo.FeaturedAdPrice.Price }; return(View(promo)); }
/// <summary> /// 获得促销单 /// </summary> /// <param name="keyWord"></param> /// <param name="status"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> public static DataSet GetPromotionSearchResult(string keyWord, int status, string startDate, string endDate) { Hashtable ht = new Hashtable(); ht.Add("KeyWords", keyWord); ht.Add("Status", status); ht.Add("DateFrom", startDate); ht.Add("DateTo", endDate); DataSet data = PromotionManager.GetInstance().GetPromotionDs(ht); return(data); }
internal static void HandleGenericRedDotNotification(JObject resJson, string vmName) { JObject jobject = JObject.Parse(resJson["bluestacks_notification"][(object)"payload"][(object)"GenericRedDotNotificationItem"].ToString()); if (JsonExtensions.IsNullOrEmptyBrackets(jobject["nyapps_cross_promotion"].ToString())) { return; } PromotionManager.AddNewMyAppsCrossPromotion((JToken)jobject); PromotionObject.Save(); string appPackage = jobject["nyapps_cross_promotion"][(object)"app_pkg"].ToString(); BlueStacksUIUtils.DictWindows[vmName].Dispatcher.Invoke((Delegate)(() => BlueStacksUIUtils.DictWindows[vmName].mWelcomeTab.mHomeAppManager.AddIconWithRedDot(appPackage))); }
/// <summary> /// Inits the marketing context. /// </summary> private void InitMarketingContext() { OrderGroup group = OrderGroup; _currency = group.BillingCurrency; SetContext(MarketingContext.ContextConstants.ShoppingCart, group); // Set customer segment context var principal = PrincipalInfo.CurrentPrincipal; if (principal != null) { CustomerProfileWrapper profile = GetCurrentUserProfile(); if (profile != null) { SetContext(MarketingContext.ContextConstants.CustomerProfile, profile); var contactId = principal.GetContactId(); var customerContact = CustomerContext.Current.GetContactById(contactId); if (contactId != group.CustomerId) { customerContact = CustomerContext.Current.GetContactById(group.CustomerId); } if (customerContact != null) { SetContext(MarketingContext.ContextConstants.CustomerContact, customerContact); Guid accountId = (Guid)customerContact.PrimaryKeyId; Guid organizationId = Guid.Empty; if (customerContact.ContactOrganization != null) { organizationId = (Guid)customerContact.ContactOrganization.PrimaryKeyId; } SetContext(MarketingContext.ContextConstants.CustomerSegments, MarketingContext.Current.GetCustomerSegments(accountId, organizationId)); } } } // Set customer promotion history context SetContext(MarketingContext.ContextConstants.CustomerId, OrderGroup.CustomerId); // Now load current order usage dto, which will help us determine the usage limits // Load existing usage Dto for the current order PromotionUsageDto usageDto = PromotionManager.GetPromotionUsageDto(0, Guid.Empty, group.OrderGroupId); SetContext(MarketingContext.ContextConstants.PromotionUsage, usageDto); }
public void SaveProductTestMethod() { using (ShimsContext.Create()) { IDoumentProvider doumentProvider = new DocumentManager(); PromotionManager productsManager = new PromotionManager(doumentProvider); Promotion item = new Promotion(); Dictionary <string, int> d1 = new Dictionary <string, int>(); d1.Add("A", 5); item.PromotionID = 4; item.ProductInfo = d1; item.PromoPrice = 200; productsManager.SavePromotion(item); Assert.IsNotNull(true); } }
/// <summary> /// Inits the marketing context. /// </summary> private void InitMarketingContext() { OrderGroup group = this.OrderGroup; SetContext(MarketingContext.ContextConstants.ShoppingCart, group); // Set customer segment context MembershipUser user = SecurityContext.Current.CurrentUser; if (user != null) { CustomerProfileWrapper profile = SecurityContext.Current.CurrentUserProfile as CustomerProfileWrapper; if (profile != null) { SetContext(MarketingContext.ContextConstants.CustomerProfile, profile); CustomerContact customerContact = CustomerContext.Current.GetContactForUser(user); if ((Guid)customerContact.PrimaryKeyId != group.CustomerId) { customerContact = CustomerContext.Current.GetContactById(group.CustomerId); } if (customerContact != null) { SetContext(MarketingContext.ContextConstants.CustomerContact, customerContact); Guid accountId = (Guid)customerContact.PrimaryKeyId; Guid organizationId = Guid.Empty; if (customerContact.ContactOrganization != null) { organizationId = (Guid)customerContact.ContactOrganization.PrimaryKeyId; } SetContext(MarketingContext.ContextConstants.CustomerSegments, MarketingContext.Current.GetCustomerSegments(accountId, organizationId)); } } } // Set customer promotion history context SetContext(MarketingContext.ContextConstants.CustomerId, this.OrderGroup.CustomerId); // Now load current order usage dto, which will help us determine the usage limits // Load existing usage Dto for the current order PromotionUsageDto usageDto = PromotionManager.GetPromotionUsageDto(0, Guid.Empty, group.OrderGroupId); SetContext(MarketingContext.ContextConstants.PromotionUsage, usageDto); }
/// <summary> /// Handles the SaveChanges event of the EditSaveControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void EditSaveControl_SaveChanges(object sender, SaveControl.SaveEventArgs e) { // Validate form if (!this.Page.IsValid) { e.RunScript = false; return; } PromotionDto promo = (PromotionDto)Session[_PromotionDtoEditSessionKey]; if (promo == null && PromotionId > 0) { promo = PromotionManager.GetPromotionDto(PromotionId); //Int32.Parse(Parameters["PromotionId"].ToString())); } if (PromotionId == 0) { promo = new PromotionDto(); } /* * // if we add a new promotion, remove all other segments from Dto that is passed to control that saves changes * if (PromotionId == 0 && promo != null && promo.Promotion.Count > 0) * { * PromotionDto.PromotionRow[] rows2del = (PromotionDto.PromotionRow[])promo.Promotion.Select(String.Format("{0} <> {1}", _PromotionIdString, PromotionId)); * if (rows2del != null) * foreach (PromotionDto.PromotionRow row in rows2del) * promo.Promotion.RemovePromotionRow(row); * }*/ IDictionary context = new ListDictionary(); context.Add(_PromotionDtoString, promo); ViewControl.SaveChanges(context); if (promo.HasChanges()) { PromotionManager.SavePromotion(promo); } // we don't need to store Dto in session any more Session.Remove(_PromotionDtoEditSessionKey); }
public void ApplyPercentagePromotionsOnProductCandD() { Dictionary <Product, int> promtion1products = new Dictionary <Product, int>(); promtion1products.Add(new Product("C"), 1); promtion1products.Add(new Product("D"), 1); List <Promotion> promotions = new List <Promotion>() { new Promotion(1, promtion1products, 0.20M, DateTime.Now.AddDays(-10), false, null), }; Order order = new Order(1, new List <Product>() { new Product("A"), new Product("A"), new Product("C"), new Product("D") }); Assert.AreEqual(128, PromotionManager.GetFinalPrice(order, promotions)); }
/// <summary> /// Inits the marketing context. /// </summary> private void InitMarketingContext() { OrderGroup group = this.OrderGroup; SetContext(MarketingContext.ContextConstants.ShoppingCart, group); // Set customer segment context MembershipUser user = ProfileContext.Current.User; if (user != null) { CustomerProfile profile = ProfileContext.Current.Profile; if (profile != null) { SetContext(MarketingContext.ContextConstants.CustomerProfile, profile); Account account = profile.Account; if (account != null) { SetContext(MarketingContext.ContextConstants.CustomerAccount, account); Guid accountId = account.PrincipalId; Guid organizationId = Guid.Empty; if (account.Organization != null) { organizationId = account.Organization.PrincipalId; } SetContext(MarketingContext.ContextConstants.CustomerSegments, MarketingContext.Current.GetCustomerSegments(accountId, organizationId)); } } } // Set customer promotion history context SetContext(MarketingContext.ContextConstants.CustomerId, ProfileContext.Current.UserId); // Now load current order usage dto, which will help us determine the usage limits // Load existing usage Dto for the current order PromotionUsageDto usageDto = PromotionManager.GetPromotionUsageDto(0, Guid.Empty, group.OrderGroupId); SetContext(MarketingContext.ContextConstants.PromotionUsage, usageDto); }
/// <summary> /// Evals the specified filter with checkEntryLevelLimit /// </summary> /// <param name="filter"> The filter</param> /// <param name="checkEntryLevelLimit"> The check Entry Level Limit</param> public void Eval(PromotionFilter filter, bool checkEntryLevelLimit) { if (checkEntryLevelLimit) { Dictionary <PromotionDto.PromotionRow, decimal?> entryDiscountApplicationCount = new Dictionary <PromotionDto.PromotionRow, decimal?>(); PromotionDto promotionDto = PromotionManager.GetPromotionDto(FrameworkContext.Current.CurrentDateTime); foreach (PromotionDto.PromotionRow promotion in promotionDto.Promotion) { if (!promotion.IsMaxEntryDiscountQuantityNull()) { entryDiscountApplicationCount.Add(promotion, promotion.MaxEntryDiscountQuantity); } } MarketingContext.Current.EvaluatePromotions(true, this.PromotionContext, filter, entryDiscountApplicationCount, true); } else { Eval(filter); } }
public JsonResult GetDepartmentUseSetting() { var result = new List <DepartmentAndUse>(); var setting = PromotionManager.GetDepartmentUseSetting(); if (setting != null && setting.Rows.Count > 0) { result = setting.Rows.OfType <System.Data.DataRow>().Select(s => new DepartmentAndUse { ParentSettingId = s["ParentSettingId"].ToString(), SettingId = s["SettingId"].ToString(), DisplayName = s["DisplayName"].ToString(), Type = s["Type"].ToString() }).ToList(); } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Processes the delete command. /// </summary> /// <param name="items">The items.</param> void ProcessDeleteCommand(string[] items) { for (int i = 0; i < items.Length; i++) { string[] keys = EcfListView.GetPrimaryKeyIdStringItems(items[i]); if (keys != null) { string id = keys[0]; using (TransactionScope scope = new TransactionScope()) { // delete selected sites PromotionDto dto = PromotionManager.GetPromotionDto(Int32.Parse(id)); List <int> expressionList = new List <int>(); if (dto.Promotion.Count > 0) { PromotionDto.PromotionRow promotionRow = dto.Promotion[0]; foreach (PromotionDto.PromotionConditionRow condition in promotionRow.GetPromotionConditionRows()) { expressionList.Add(condition.ExpressionId); } dto.Promotion[0].Delete(); PromotionManager.SavePromotion(dto); // Delete corresponding expressions foreach (int expressionId in expressionList) { ExpressionDto expressionDto = ExpressionManager.GetExpressionDto(expressionId); if (expressionDto != null && expressionDto.Expression.Count > 0) { expressionDto.Expression[0].Delete(); ExpressionManager.SaveExpression(expressionDto); } } } scope.Complete(); } } } }
public ActionResult GetCategory(string type) { var source = PromotionManager.SelectProductCategoryCategoryNameAndDisplayName().Where(s => s.ParentCategory == null || !s.ParentCategory.Any()).ToList(); if (string.IsNullOrWhiteSpace(type)) { return(Json(null, JsonRequestBehavior.AllowGet)); } if (type.Equals("category")) { foreach (var c in source) { var children = new List <Category>(); childCategory(children, c); c.ChildrenCategory = children; } return(Json(source.Select(r => new { name = r.DisplayName, open = false, title = r.CategoryName, children = r.ChildrenCategory.Select(c => new { name = c.DisplayName, title = c.CategoryName }) }), JsonRequestBehavior.AllowGet)); } else { var result = source.Select(r => new Category() { DisplayName = r.DisplayName, CategoryName = r.CategoryName, ChildrenCategory = (r.DisplayName == "礼品" || r.DisplayName == "轮胎" || r.DisplayName == "轮毂") ? new List <Category>() : r.ChildrenCategory.Select(c => new Category() { DisplayName = c.DisplayName, CategoryName = c.CategoryName, ChildrenCategory = c.ChildrenCategory == null ? new List <Category>() : c.ChildrenCategory.Select(cc => new Category() { DisplayName = cc.DisplayName, CategoryName = cc.CategoryName, ChildrenCategory = new List <Category>() }) }) }); return(Json(result, JsonRequestBehavior.AllowGet)); } }
private void CreatePromotions(int campaignId) { var dto = new PromotionDto(); CreatePromotion(dto, "25 % off Mens Shoes", 0.00m, PromotionType.Percentage, "EntryCustomDiscount", "entry", campaignId); CreatePromotion(dto, "$50 off Order over $500", 50.00m, PromotionType.ValueBased, "OrderVolumeDiscount", "order", campaignId); CreatePromotion(dto, "$10 off shipping from Women's Shoes", 10.00m, PromotionType.ValueBased, "BuySKUFromCategoryXGetDiscountedShipping", "shipping", campaignId); PromotionManager.SavePromotion(dto); dto = PromotionManager.GetPromotionDto(); foreach (var promotion in dto.Promotion) { foreach (var languageCode in new[] { "en", "sv" }) { var name = String.Empty; switch (promotion.PromotionId) { case 1: name = languageCode.Equals("en") ? "25 % off Mens Shoes" : "25% rabatt på herrskor"; break; case 2: name = languageCode.Equals("en") ? "$50 off Order over $500" : "$50 rabatt på order över $500"; break; case 3: name = languageCode.Equals("en") ? "$10 off shipping from Women's Shoes" : "$10 rabatt på frakt av Damskor"; break; } var promoLanguageRow = dto.PromotionLanguage.NewPromotionLanguageRow(); promoLanguageRow.PromotionId = promotion.PromotionId; promoLanguageRow.LanguageCode = languageCode; promoLanguageRow.DisplayName = name; dto.PromotionLanguage.Rows.Add(promoLanguageRow); } } PromotionManager.SavePromotion(dto); UpdatePromotionParams(); CreateExpression(1, "25 % off Mens Shoes"); CreateExpression(2, "$50 off Order over $500"); CreateExpression(3, "$10 off shipping from Women's Shoes"); }
/// <summary> /// Deletes the current basket instance from the database. /// </summary> public virtual void Delete() { // Remove any reservations // Load existing usage Dto for the current order PromotionUsageDto usageDto = PromotionManager.GetPromotionUsageDto(0, Guid.Empty, this.Cart.OrderGroupId); // Clear all old items first if (usageDto.PromotionUsage.Count > 0) { foreach (PromotionUsageDto.PromotionUsageRow row in usageDto.PromotionUsage) { row.Delete(); } } // Save the promotion usage PromotionManager.SavePromotionUsage(usageDto); // Delete the cart this.Cart.Delete(); }
private void populateManagerialPosition(string branch) { DropDManagPosition.Items.Clear(); DropDManagPosition.Items.Add(new ListItem(" -- SELECT --", "-1")); DataTable dataTable = null; try { PromotionManager promotionManager = new PromotionManager(); dataTable = promotionManager.getmanagerialPosition(branch); if (dataTable != null && dataTable.Rows.Count > 0) { // PROCESSOR DropDManagPosition.DataSource = dataTable; DropDManagPosition.DataValueField = "Emp_ID"; DropDManagPosition.DataTextField = "empDetail"; DropDManagPosition.DataBind(); btnSave.Visible = true; } else { clearmsgPanel(); msgPanel.Visible = true; InfoDIV.Visible = true; lblInformationMsg.Text = "The selected Employee doesnt have a manager, please check and try again."; btnSave.Visible = false; } } //CATCH ANY OTHER EXCEPTION, dont let user see any kind of unexpected error catch (Exception ex) { //Write this exception to file for investigation of the issue later. LoggerManager.LogError(ex.ToString(), logger); } }
protected void btnReg_Click(object sender, EventArgs e) { clearMsgLabel(); resetLabelControl(); Promotion promotion = new Promotion(); bool validationResult = ValidateInputAndFillPromotion(promotion); bool checkPromo = checkPromotedEmployee(); if (!checkPromo) { btnReg.Visible = false; btnAddNewIntrenal.Visible = true; return; } //if Data is not valid - stop the flow if (!validationResult) { return; } //continue otherwise PromotionManager promotionManager = new PromotionManager(promotion); TransactionResponse response = promotionManager.addNewPromotion(); //if store to DB is successful, register notification for this Promotion if (response.isSuccessful()) { //Register Notification for the promotion assigned to HR Manager. string notificationRegistractionMessage = registerNotification(promotion); msgPanel.Visible = true; SucessDIV.Visible = true; lblSuccessMessage.Text = response.getMessage() + notificationRegistractionMessage; btnReg.Visible = false; btnAddNewIntrenal.Visible = true; } // show error message to a user. else { msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = "(" + response.getErrorCode() + ") " + response.getMessage(); } }
protected void btnRegExtrenal_Click(object sender, EventArgs e) { clearMsgLabel(); resetLabelControl(); Promotion promotion = new Promotion(); Employee employee = new Employee(); //if Data is not valid - stop the flow if (!ValidateInputAndFillPromotionEmployee(promotion, employee)) { return; } //continue otherwise PromotionManager promotionManager = new PromotionManager(promotion); EmployeeManager employeeManager = new EmployeeManager(employee); TransactionResponse response = null; //For other district employee we need to register there information both on promotion table and other district promotion response = promotionManager.addNewPromotionForOtherDistrict(); response = employeeManager.storeEmployeefromOtherDistrictForPromotion(txtOtherMinNo.Text.Trim(), PageAccessManager.getDistrictID()); //if store to DB is successful, register notification for this Promotion if (response.isSuccessful()) { msgPanel.Visible = true; SucessDIV.Visible = true; lblSuccessMessage.Text = response.getMessage(); btnRegExtrenal.Visible = false; btnCancelExtrenal.Visible = true; } // show error message to a user. else { msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = "(" + response.getErrorCode() + ") " + response.getMessage(); } }
protected void PromotionGV_RowUpdating(object sender, GridViewUpdateEventArgs e) { clearMsgPanel(); int index = PromotionGV.EditIndex; GridViewRow row = PromotionGV.Rows[index]; DropDownList PrevBranch = (DropDownList)row.FindControl("DropPrevBranch"); DropDownList ExpectedBranch = (DropDownList)row.FindControl("DropExpecBranch"); TextBox MinNo = (TextBox)row.FindControl("txtMinNo"); DropDownList jTitle = (DropDownList)row.FindControl("DropDJobTitle"); DropDownList status = (DropDownList)row.FindControl("DropDStatus"); TextBox PromotionDate = (TextBox)row.FindControl("txtPromotionDate"); string tempPromotionDate = null; try { tempPromotionDate = Convert.ToDateTime(PromotionDate.Text).ToShortDateString(); } catch (FormatException) { msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = "Please check the Promotion date & try again."; return; } catch (Exception) { msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = "Something went wrong please contact your system administrator"; return; } promotion.PrevBranch = PrevBranch.SelectedValue; promotion.Branch = ExpectedBranch.SelectedValue; promotion.MinuteNo = MinNo.Text.Trim(); promotion.Post = jTitle.SelectedValue; promotion.Status = status.SelectedValue; promotion.PromotionDate = tempPromotionDate; promotionManagement = new PromotionManager(promotion); promotionManagement.UpdatePromotedemployee(); PromotionGV.EditIndex = -1; DataTable getds = null; if (isAllPromotion) { getds = promotionManagement.getAllPromotedEmployee(promotionStatus, dateStart.Text.Trim(), DateEnd.Text.Trim()); } else { getds = promotionManagement.getSpecifiedPromotionResult(postID, isPromoAssigned); } BindDataSetToGV(getds); }
protected void btnRegister_Click(object sender, EventArgs e) { clearLabelMsg(); Vacancy vacancy = new Vacancy(); if (!validateAllData(vacancy) && isGeneralOrGSpecific != 0) { return; } VacancyRegistrationAndEvaluationManager manager = new VacancyRegistrationAndEvaluationManager(vacancy); TransactionResponse response = manager.addNewVacancy(); if (response.isSuccessful()) { //update promotion table for the specified minute number Promotion promotion = new Promotion(); if (vacancy.VacancyOpenedFor == "2") { if (DropDPromMinNumb.SelectedValue != "-1") { string[] splitter = new string[] { PageConstants.GREATER_GREATER_THAN }; MinNumInfo = (DropDPromMinNumb.SelectedValue).Split(splitter, StringSplitOptions.RemoveEmptyEntries); applicantEID = MinNumInfo[0].Trim(); MinNumber = MinNumInfo[1].Trim(); promotion.EmpID = applicantEID; promotion.MinuteNo = MinNumber; PromotionManager promotionManager = new PromotionManager(promotion); TransactionResponse promotionResponse = promotionManager.updatePromotion(promotion, vacancy.VacancyNo); if (!promotionResponse.isSuccessful()) { clearLabelMsg(); msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = promotionResponse.getMessage(); return; } } else { lblvacForPromotion.Visible = true; lblvacForPromotion.Text = "You can't register vacancy for promotion now. If you want to register vacancy for promotion please first register promotion."+ "Or if promotion is already registered please contact you manager to assign promotion to you."; } } clearLabelMsg(); msgPanel.Visible = true; SucessDIV.Visible = true; lblSuccessMessage.Text = response.getMessage(); btnRegister.Visible = false; btnCancel.Visible = true; PromotionAssigment promotionAssigment = new PromotionAssigment(); promotionAssigment.MinuteNo = MinNumber; if (isVacncyForPromotion) { //REMOVE THIS TASK FROM HR_MANGERS MAIL BOX NotificationManager notificationManager = new NotificationManager(promotion); TransactionResponse delteResponse = notificationManager.deleteNotificationForAssignedPromotionforSpecificHROfficer(Membership.GetUser()); if (!delteResponse.isSuccessful()) { //check if Warning Message is already logged, if so just add on it if (WarnDIV.Visible) { msgPanel.Visible = true; ErroroDIV.Visible = true; lblWarningMsg.Text = lblWarningMsg.Text + " and " + delteResponse.getMessage() + delteResponse.getErrorCode(); } else { msgPanel.Visible = true; ErroroDIV.Visible = true; lblWarningMsg.Text = delteResponse.getMessage() + delteResponse.getErrorCode(); } } } } else { msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = response.getMessage() + response.getErrorCode(); } }
protected void btnAssignPromotion_Click(object sender, EventArgs e) { clearMsgPanel(); PromotionAssigment promotionAssigment = new PromotionAssigment(); if (vaidateInputAndFillData(promotionAssigment)) { PromotionManager promotionAssigmentManager = new PromotionManager(promotionAssigment); TransactionResponse response = promotionAssigmentManager.addNewPromotionAssignment(); if (response.isSuccessful()) { msgPanel.Visible = true; SucessDIV.Visible = true; lblSuccessMessage.Text = response.getMessage(); AssignPromotionPanel.Visible = true; btnAssignNew.Visible = true; btnAssignPromotion.Visible = false; //REGISTER NOTIFICATION ABOUT THIS ASSIGNMENT TO HR OFFICER //HERE THE CIRRENT USER (i.e., HR Manager) IS THE SENDER AND HR OFFICERs ARE THE RECEIVERS NotificationManager notificationManager = new NotificationManager(promotionAssigment); TransactionResponse notificationResponse = notificationManager.addNotificationForPromotioAssignement(Membership.GetUser()); if (!notificationResponse.isSuccessful()) { msgPanel.Visible = true; WarnDIV.Visible = true; lblWarningMsg.Text = notificationResponse.getMessage() + notificationResponse.getErrorCode(); } //REMOVE THIS TASK FROM HR_MANGERS MAIL BOX TransactionResponse delteResponse = notificationManager.deleteNotificationForAssignedPromotion(Membership.GetUser()); if (!delteResponse.isSuccessful()) { //check if Warning Message is already logged, if so just add on it if (WarnDIV.Visible) { msgPanel.Visible = true; lblWarningMsg.Text = lblWarningMsg.Text + " and " + delteResponse.getMessage() + delteResponse.getErrorCode(); } else { msgPanel.Visible = true; WarnDIV.Visible = true; lblWarningMsg.Text = delteResponse.getMessage() + delteResponse.getErrorCode(); } } Promotion promotion = new Promotion(); promotion.MinuteNo = promotionAssigment.MinuteNo; PromotionManager promotionManager = new PromotionManager(promotion); TransactionResponse promotionResponse = promotionManager.updatePromotionStatus(promotion, PromotionConstants.PROMOTION_ASSIGNED); if (!promotionResponse.isSuccessful()) { msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = "Error occured while update promotion status. Please contact your system administrator."; return; } } else { msgPanel.Visible = true; WarnDIV.Visible = true; lblWarningMsg.Text = response.getMessage() + response.getErrorCode(); } } }
protected void btnConfirmComplete_Click(object sender, EventArgs e) { PromotionAssigment promotionAssigment = new PromotionAssigment(); string minNo = DropDownLMinuteNo.SelectedItem.Text; if (minNo != "-1") { lblminNo.Visible = false; string[] splitVacancyDetail = minNo.Split(new string[] { PageConstants.GREATER_GREATER_THAN }, StringSplitOptions.None); promotionAssigment.MinuteNo = splitVacancyDetail[1].Trim(); } else { resetAllControl(); lblminNo.Visible = true; return; } Promotion promotion = new Promotion(); promotion.MinuteNo = promotionAssigment.MinuteNo; PromotionManager promotionManager = new PromotionManager(promotion); TransactionResponse promotionResponse = promotionManager.updatePromotionStatus(promotion, PromotionConstants.PROMOTION_NOT_NEED_VACANCY_CANT_POSTED_BY_DISTRICT); if (!promotionResponse.isSuccessful()) { msgPanel.Visible = true; ErroroDIV.Visible = true; lblErrorMsg.Text = "Error occured while update promotion status. Please contact your system administrator."; return; } //REMOVE THIS TASK FROM HR_MANGERS MAIL BOX NotificationManager notificationManager = new NotificationManager(promotionAssigment); TransactionResponse delteResponse = notificationManager.deleteNotificationForAssignedPromotion(Membership.GetUser()); if (!delteResponse.isSuccessful()) { //check if Warning Message is already logged, if so just add on it if (WarnDIV.Visible) { msgPanel.Visible = true; lblWarningMsg.Text = lblWarningMsg.Text + " and " + delteResponse.getMessage() + delteResponse.getErrorCode(); } else { msgPanel.Visible = true; WarnDIV.Visible = true; lblWarningMsg.Text = delteResponse.getMessage() + delteResponse.getErrorCode(); } } else { PanelConfirmVacancyComplete.Visible = false; msgPanel.Visible = true; SucessDIV.Visible = true; lblSuccessMessage.Text = "Operation Success!"; btnAssignNew.Visible = false; btnAssignPromotion.Visible = true; populateAssignedPromotion(); AssignPromotionPanel.Visible = true; } }