public IEnumerable <PromotionInformation> ApplyReward() { if (this._variation != null) { if (!_orderGroup.OrderForms[0].LineItems.Any(i => i.Code == _variation.Code)) { var entry = CatalogContext.Current.GetCatalogEntry(_variation.Code); LineItem item = CreateLineItem(entry, _orderGroup); item.PlacedPrice = 0; _orderGroup.OrderForms[0].LineItems.Add(item); } PromotionInformation iteratorVariable1 = new PromotionInformation { Description = this.Description, SavedAmount = 100, ContentLink = this._variation.ContentLink, IsActive = true }; yield return(iteratorVariable1); } else { PromotionInformation iteratorVariable0 = new PromotionInformation { Description = this.Description }; yield return(iteratorVariable0); } }
/*===INSERT CONTROLLER===*/ public bool insertNewPromotion(string productCode, float promotionPrice, DateTime startTime, DateTime endTime, string promotionContent, string promotionImage) { try { using (var db = new CMART2Entities1()) { ObjectParameter idoutput = new ObjectParameter("Code", typeof(String)); db.SP_PROMOTIONINFORMATION_ID_AUTO(idoutput); var id_auto = idoutput.Value.ToString(); var promotion = new PromotionInformation { PromotionCode = id_auto, ProductCode = productCode, PricePromotion = promotionPrice, StartTime = startTime, EndTime = endTime, Cont = promotionContent, Image = promotionImage }; db.PromotionInformations.Add(promotion); db.SaveChanges(); return(true); } } catch (Exception) { return(false); } }
public async Task DeletePromotionInformationById(int id) { if (PromotionInformationExists(id)) { PromotionInformation promoInfo = await _ctx.PromotionsInformation.FindAsync(id); try { _ctx.PromotionsInformation.Remove(promoInfo); await _ctx.SaveChangesAsync(); } catch (Exception ex) { _logger.LogInformation($"Promotion information record not deleted: {ex.Message}"); } } throw new Exception(); }
public async Task UpdatPromotionInformationWithId(PromotionInformationDto promotionInformationDto) { if (PromotionInformationExists(promotionInformationDto.PromotionInformationId)) { PromotionInformation promotionInformation = null; string path = null; try { path = _img.EditImage(promotionInformationDto.File, promotionInformationDto.OldImage); } catch (Exception ex) { _logger.LogInformation($"Product information image not created: {ex.Message}"); } promotionInformation = await _ctx.PromotionsInformation.Where(p => p.PromotionInformationId == promotionInformationDto.PromotionInformationId) .Select(p => new PromotionInformation { ImagePath = !string.IsNullOrEmpty(path) ? path : p.ImagePath, PromotionId = promotionInformationDto.PromotionId, PromotionInformationId = p.PromotionInformationId, PromotionInformationContent = promotionInformationDto.PromotionInformationContent, Title = promotionInformationDto.Title, Price = promotionInformationDto.Price }).SingleOrDefaultAsync(); try { _ctx.Update(promotionInformation); await _ctx.SaveChangesAsync(); return; } catch (Exception ex) { _logger.LogInformation($"Promotion information record not updated: {ex.Message}"); } } throw new Exception(); }
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 async Task AddPromotionInformation(PromotionInformationDto promotionInformationDto) { if (promotionInformationDto.File != null) { PromotionInformation promotionInformation = null; string path = null; try { path = _img.CreateImage(promotionInformationDto.File); } catch (Exception ex) { _logger.LogInformation($"Banner image not created: {ex.Message}"); } promotionInformation = new PromotionInformation { ImagePath = path, PromotionId = promotionInformationDto.PromotionId, PromotionInformationContent = promotionInformationDto.PromotionInformationContent, Title = promotionInformationDto.Title, Price = promotionInformationDto.Price }; try { _ctx.PromotionsInformation.Add(promotionInformation); await _ctx.SaveChangesAsync(); return; } catch (Exception ex) { _logger.LogInformation($"Banner record not created: {ex.Message}"); } } throw new Exception(); }
public IEnumerable<PromotionInformation> ApplyReward() { if (this._variation != null) { if (!_orderGroup.OrderForms[0].LineItems.Any(i => i.Code == _variation.Code)) { var entry = CatalogContext.Current.GetCatalogEntry(_variation.Code); LineItem item = CreateLineItem(entry, _orderGroup); item.PlacedPrice = 0; _orderGroup.OrderForms[0].LineItems.Add(item); } PromotionInformation iteratorVariable1 = new PromotionInformation { Description = this.Description, SavedAmount = 100, ContentLink = this._variation.ContentLink, IsActive = true }; yield return iteratorVariable1; } else { PromotionInformation iteratorVariable0 = new PromotionInformation { Description = this.Description }; yield return iteratorVariable0; } }