public PromotionController(ILogger <PromotionController> logger, [FromServices] EnvReader envReader, [FromServices] PromotionData promotionData, ZhaoContext context) { _logger = logger; _envReader = envReader; _promotionData = promotionData; _context = context; }
EcommercePromotion generatePromotion(PromotionData prom) { var promotion = new EcommercePromotion(); if (!string.IsNullOrEmpty(prom?.Id)) { promotion.SetId(prom.Id); } if (!string.IsNullOrEmpty(prom?.Name)) { promotion.SetName(prom.Name); } if (!string.IsNullOrEmpty(prom?.Creative)) { promotion.SetCreative(prom.Creative); } if (!string.IsNullOrEmpty(prom?.Position)) { promotion.SetPosition(prom.Position); } return(promotion); }
/// <summary> /// Get de una promocion especifica /// </summary> /// <param name="id"></param> /// <returns></returns> public PromotionData GetPromotion(string id) { PromotionData promotion = new PromotionData(); using (tecAirlinesEntities entities = new tecAirlinesEntities()) { try { if (!this.ExistPromotion(id)) { promotion = null; return(promotion); } var promox = entities.Promocions.Find(id); promotion.C_Usuario = promox.C_Usuario; promotion.C_Vuelo = promox.C_Vuelo; promotion.F_Inicio = promox.F_Inicio; promotion.F_Fin = promox.F_Fin; promotion.Porcentaje = promox.Porcentaje; promotion.Imagen = promox.Imagen; return(promotion); } catch (Exception) { promotion = null; return(promotion); } } }
public static PromotionData BuildPromoFields(ListPage <OrderPromotion> promotions, ReportTypeEnum reportType, string supplierID = null, List <HSLineItem> discountedLineItems = null) { var uniquePromotions = promotions.Items.GroupBy(promotion => promotion.Code).Select(promo => promo.First()); if (reportType == ReportTypeEnum.PurchaseOrderDetail) { var supplierRelatedPromotions = new List <OrderPromotion>(); foreach (var promo in uniquePromotions) { if (!promo.LineItemLevel) { supplierRelatedPromotions.Add(promo); continue; } if (promo.xp?.Supplier == supplierID) { supplierRelatedPromotions.Add(promo); continue; } foreach (var sku in promo.xp?.SKUs) { if (discountedLineItems.Any(line => line.ProductID == sku && line.SupplierID == supplierID)) { supplierRelatedPromotions.Add(promo); } } } uniquePromotions = supplierRelatedPromotions; } var reportFormattedPromoData = new PromotionData(); foreach (var promo in uniquePromotions) { var delimiter = ""; if (reportFormattedPromoData.PromoCode != null) { delimiter = " | "; } // Promotions always have values for these fields reportFormattedPromoData.PromoCode += delimiter + promo.Code; reportFormattedPromoData.SupplierSpecific += delimiter + promo.xp?.ScopeToSupplier.ToString().ToLower(); reportFormattedPromoData.OrderLevelPromo += delimiter + (!promo.LineItemLevel).ToString().ToLower(); reportFormattedPromoData.LineItemLevelPromo += delimiter + promo.LineItemLevel.ToString().ToLower(); if (reportFormattedPromoData.PromoSupplierName == null) { delimiter = ""; } // Field could be null reportFormattedPromoData.PromoSupplierName += delimiter + promo.xp?.Supplier; } return(reportFormattedPromoData); }
public void TrackScreen( string screenName, string campaignUrl, List <ProductData> products, ProductActions productAction, ActionData actionData, PromotionData promotion, List <CustomDimension> customDimensions, List <CustomMetric> customMetrics ) { analyticsTracker.Set(GaiConstants.ScreenName, screenName); var builder = DictionaryBuilder.CreateScreenView(); if (customDimensions?.Count > 0) { foreach (var customDimension in customDimensions) { builder.Set(customDimension.DimensionValue, Fields.CustomDimension((nuint)customDimension.DimensionIndex)); } } if (customMetrics?.Count > 0) { foreach (var customMetric in customMetrics) { builder.Set(Convert.ToString(customMetric.MetricValue), Fields.CustomMetric((nuint)customMetric.MetricIndex)); } } if (promotion != null) { builder.AddPromotion(generatePromotion(promotion)); } if (products != null) { foreach (var p in products) { var product = mapper.mapProduct(p); switch (productAction) { case ProductActions.none: builder.AddProductImpression(product, screenName, "App"); break; default: builder.SetProductAction(generateCheckoutProductAction(actionData, productAction)); builder.AddProduct(product); break; } } } analyticsTracker.Send(builder.Build()); }
public BaseViewModel() { establishmentAgent = new EstablishmentData(appSettings); promotionAgent = new PromotionData(appSettings); comboAgent = new ComboData(appSettings); tableAgent = new TableData(appSettings); menuAgent = new MenuData(appSettings); bookAgent = new BookData(appSettings); notificationAgent = new NotificationData(oneSignal); contactAgent = new ContactData(appSettings); categoryAgent = new CategoryData(appSettings); activityAgent = new ActivityData(appSettings); }
public IActionResult Promote(PromotionData data) { Enrollment enrollment = _studentsDbService.Promote(data); if (enrollment is null) { return(BadRequest()); } else { return(StatusCode(201, enrollment)); } }
public IActionResult PromoteStudents(PromotionData data) { var enrollment = _dbService.PromoteStudents(data); if (enrollment is null) { return(BadRequest()); } else { return(Ok(enrollment)); } }
public static void JsonParserToList(string filePath, PromotionData promotionData) { try { using (StreamReader r = new StreamReader(filePath)) { string json = r.ReadToEnd(); promotionData = Newtonsoft.Json.JsonConvert.DeserializeObject <PromotionData>(json); Global.activePromotions = promotionData.ActivePromotion.ToList(); Global.skuIdPrice = promotionData.SkuIdPrice.ToList(); } } catch (System.Exception) { throw; } }
public IHttpActionResult AddPromotion([FromBody] PromotionData data) { if (data == null) { //Bad request code 400 return(BadRequest()); } if (promotionLogic.AddPromotion(data)) { //petición correcta y se ha creado un nuevo recurso code 201 return(StatusCode(HttpStatusCode.Created)); } else { //No se pudo crear el recurso por un error interno code 500 return(InternalServerError()); } }
public IHttpActionResult GetPromotion(string id) { if (!promotionLogic.ExistPromotion(id)) { //No se encontró el recurso code 404 return(NotFound()); } PromotionData user = promotionLogic.GetPromotion(id); if (user != null) { // ok code 200 return(Ok(user)); } else { //No se pudo crear el recurso por un error interno code 500 return(InternalServerError()); } }
/// <summary> /// Actualizar una promocion /// </summary> /// <param name="data"></param> /// <returns></returns> public bool UpdatePromotion(PromotionData data) { using (tecAirlinesEntities entities = new tecAirlinesEntities()) { try { var promotion = entities.Promocions.Find(data.C_Vuelo); promotion.C_Usuario = data.C_Usuario; promotion.C_Vuelo = data.C_Vuelo; promotion.F_Inicio = data.F_Inicio; promotion.F_Fin = data.F_Fin; promotion.Porcentaje = data.Porcentaje; promotion.Imagen = data.Imagen; return(true); } catch (Exception e) { return(false); } } }
/// <summary> /// Lista de promociones /// </summary> /// <returns></returns> public List <object> GetPromotions() { List <Object> dataList = new List <object>(); using (tecAirlinesEntities entities = new tecAirlinesEntities()) { try { var promotionList = entities.Promocions.ToList(); int n = promotionList.Count; if (n == 0) { dataList = null; return(dataList); } else { for (int i = 0; i < promotionList.Count; ++i) { PromotionData data = new PromotionData(); data.C_Usuario = promotionList.ElementAt(i).C_Usuario; data.C_Vuelo = promotionList.ElementAt(i).C_Vuelo; data.F_Inicio = promotionList.ElementAt(i).F_Inicio; data.F_Fin = promotionList.ElementAt(i).F_Fin; data.Porcentaje = promotionList.ElementAt(i).Porcentaje; data.Imagen = promotionList.ElementAt(i).Imagen; dataList.Add(data); } return(dataList); } } catch { dataList = null; return(dataList); } } }
private void CheckMultiple(PromotionData promotion, PromotionInformation promotionInformation) { var uniqueCodes = _uniqueCouponService.GetByPromotionId(promotion.ContentLink.ID); if (uniqueCodes == null || !uniqueCodes.Any()) { return; } var uniqueCode = uniqueCodes.FirstOrDefault(x => x.Code.Equals(promotionInformation.CouponCode, StringComparison.OrdinalIgnoreCase)); if (uniqueCode == null) { return; } uniqueCode.UsedRedemptions++; _uniqueCouponService.SaveCoupons(new List <UniqueCoupon> { uniqueCode }); }
public Enrollment PromoteStudents(PromotionData data) { /* Check if old enrollment exists */ if (!_context.Enrollment.Include(e => e.IdStudyNavigation).Any(e => e.Semester == Convert.ToInt32(data.Semester) && e.IdStudyNavigation.Name.Equals(data.Name))) { return(null); } /* Get old enrollment */ Enrollment oldEnrollment = _context.Enrollment .Include(e => e.IdStudyNavigation) .First(e => e.Semester == Convert.ToInt32(data.Semester) && e.IdStudyNavigation.Name.Equals(data.Name)); Enrollment newEnrollment = null; /* Check if new enrollment exists */ if (!_context.Enrollment.Any(e => e.IdStudy == oldEnrollment.IdStudy && e.Semester == Convert.ToInt32(data.Semester) + 1)) { int newId = _context.Enrollment.Max(e => e.IdEnrollment) + 1; newEnrollment = new Enrollment(newId, oldEnrollment.Semester + 1, oldEnrollment.IdStudy, DateTime.Now.Date); _context.Enrollment.Add(newEnrollment); _context.SaveChanges(); } else { newEnrollment = _context.Enrollment.First(e => e.IdStudy == oldEnrollment.IdStudy && e.Semester == Convert.ToInt32(data.Semester) + 1); } /* Update students */ _context.Student .Where(s => s.IdEnrollment == oldEnrollment.IdEnrollment) .ToList() .ForEach(s => s.IdEnrollment = newEnrollment.IdEnrollment); _context.SaveChanges(); return(newEnrollment); }
private IEnumerable <RedemptionDescription> GetRedemptionDescriptions( PromotionData promotionData , PromotionProcessorContext context , IList <string> applicableEntryCodes) { List <RedemptionDescription> redemptionDescriptions = new List <RedemptionDescription>(); var maxRedemptions = GetMaxRedemptions(promotionData.RedemptionLimits); var affectedEntries = context.EntryPrices.ExtractEntries(applicableEntryCodes, 1); for (int i = 0; i < maxRedemptions; i++) { if (affectedEntries == null) { break; } redemptionDescriptions.Add(CreateRedemptionDescription(affectedEntries)); } return(redemptionDescriptions); }
public IHttpActionResult UpdatePromotion([FromBody] PromotionData data) { if (data == null) { //Bad request code 400 return(BadRequest()); } if (!promotionLogic.ExistPromotion(data.C_Vuelo)) { //petición correcta pero no pudo ser procesada porque no existe el archivo code 404 return(NotFound()); } if (promotionLogic.UpdatePromotion(data)) { //petición correcta y se ha creado un nuevo recurso code 200 ok return(Ok()); } else { //No se pudo crear el recurso por un error code 500 return(InternalServerError()); } }
/// <summary> /// Agrega un nueva promocion /// </summary> /// <param name="data"></param> /// <returns></returns> public bool AddPromotion(PromotionData data) { using (tecAirlinesEntities entities = new tecAirlinesEntities()) { Promocion newPromotion = new Promocion(); newPromotion.C_Usuario = data.C_Usuario; newPromotion.C_Vuelo = data.C_Vuelo; newPromotion.F_Inicio = data.F_Inicio; newPromotion.F_Fin = data.F_Fin; newPromotion.Porcentaje = data.Porcentaje; newPromotion.Imagen = data.Imagen; try { entities.Promocions.Add(newPromotion); entities.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }
private bool IsActive(PromotionData promotion, SalesCampaign campaign) { var status = _campaignInfoExtractor.GetEffectiveStatus(promotion, campaign); return(status == CampaignItemStatus.Active); }
private bool IsValid(PromotionData promotion, IMarket market) { var campaign = _contentLoader.Get <SalesCampaign>(promotion.ParentLink); return(IsActive(promotion, campaign) && IsValidMarket(campaign, market)); }
private bool IsActive(PromotionData promotion, SalesCampaign campaign) { var status = _campaignInfoExtractor.GetEffectiveStatus(promotion, campaign); return status == CampaignItemStatus.Active; }
private void CheckMultipleCoupons(PromotionFilterContext filterContext, IList <string> couponCodes, PromotionData includedPromotion, List <UniqueCoupon> uniqueCoupons) { foreach (var couponCode in uniqueCoupons) { // Check if the code its assigned to the user and that has not been used if (couponCodes.Contains(couponCode.Code, GetCodeEqualityComparer()) && couponCode.UsedRedemptions < couponCode.MaxRedemptions) { filterContext.AddCouponCode(includedPromotion.ContentGuid, couponCode.Code); return; } } filterContext.ExcludePromotion(includedPromotion, FulfillmentStatus.CouponCodeRequired, filterContext.RequestedStatuses.HasFlag(RequestFulfillmentStatus.NotFulfilled)); }
private void CheckSingleCoupon(PromotionFilterContext filterContext, IEnumerable <string> couponCodes, string couponCode, PromotionData includedPromotion) { if (couponCodes.Contains(couponCode, GetCodeEqualityComparer())) { filterContext.AddCouponCode(includedPromotion.ContentGuid, couponCode); } else { filterContext.ExcludePromotion( includedPromotion, FulfillmentStatus.CouponCodeRequired, filterContext.RequestedStatuses.HasFlag(RequestFulfillmentStatus.NotFulfilled)); } }
public void TrackScreen( string screenName, string campaignUrl, List <ProductData> products, ProductActions productAction, ActionData actionData, PromotionData promotion, List <CustomDimension> customDimensions, List <CustomMetric> customMetrics ) { analyticsTracker.SetScreenName(screenName); var builder = new HitBuilders.ScreenViewBuilder(); if (customDimensions?.Count > 0) { foreach (var customDimension in customDimensions) { builder.SetCustomDimension(customDimension.DimensionIndex, customDimension.DimensionValue); } } if (customMetrics?.Count > 0) { foreach (var customMetric in customMetrics) { builder.SetCustomMetric(customMetric.MetricIndex, customMetric.MetricValue); } } if (!string.IsNullOrWhiteSpace(campaignUrl)) { builder.SetCampaignParamsFromUrl(campaignUrl); } if (promotion != null) { builder.AddPromotion(generatePromotion(promotion)); } if (products != null) { foreach (var p in products) { var product = mapper.mapProduct(p); switch (productAction) { case ProductActions.none: builder.AddImpression(product, screenName); break; default: builder.SetProductAction(generateCheckoutProductAction(actionData, productAction)); builder.AddProduct(product); break; } } } analyticsTracker.Send(builder.Build()); }
public Enrollment Promote(PromotionData data) { Enrollment enrollment = new Enrollment(); using (var connection = new SqlConnection(CONNECTION_STRING)) { using (var command = new SqlCommand()) { command.Connection = connection; connection.Open(); /* Check if enrollment with studies and semester provided exists */ command.CommandType = System.Data.CommandType.Text; command.CommandText = "SELECT * FROM Enrollment e " + "JOIN Studies s ON s.IdStudy = e.IdStudy " + "WHERE e.Semester = @Semester AND s.Name = @Name"; command.Parameters.AddWithValue("@Semester", data.Semester); command.Parameters.AddWithValue("@Name", data.Name); var reader = command.ExecuteReader(); if (!reader.Read()) { reader.Close(); return(null); } reader.Close(); /* Execute procedure */ command.CommandText = "PromoteStudents"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Clear(); command.Parameters.AddWithValue("@StudyName", data.Name); command.Parameters.AddWithValue("@Semester", data.Semester); command.ExecuteNonQuery(); /* Get new enrollment object */ command.Parameters.Clear(); command.CommandType = System.Data.CommandType.Text; command.CommandText = "SELECT Semester, StartDate, s.Name as Name FROM Enrollment e " + "JOIN Studies s ON s.IdStudy = e.IdStudy " + "WHERE e.Semester = @Semester AND s.Name = @Name"; Console.WriteLine((Convert.ToInt32(data.Semester) + 1).ToString()); command.Parameters.AddWithValue("@Semester", (Convert.ToInt32(data.Semester) + 1).ToString()); command.Parameters.AddWithValue("@Name", data.Name); reader = command.ExecuteReader(); reader.Read(); enrollment.Studies = reader["Name"].ToString(); enrollment.Semester = reader["Semester"].ToString(); enrollment.StartDate = reader["StartDate"].ToString(); reader.Close(); } } return(enrollment); }
public PromotionController(IOptions <AppSettings> appSettings) { _promotionAgent = new PromotionData(appSettings.Value); }
private bool IsValid(PromotionData promotion, IMarket market) { var campaign = _contentLoader.Get<SalesCampaign>(promotion.ParentLink); return IsActive(promotion, campaign) && IsValidMarket(campaign, market); }