/// <summary> /// Indexes the specified model. /// </summary> /// <returns>DataTable Pagging</returns> public async Task <IActionResult> AddBulkPromition() { BulkPromotionViewModel model = new BulkPromotionViewModel { PromotionTypeItems = (await this.promotionService.GetPromotionTypeItems()).ToSelectList(), MarginTypeItems = (await this.cancellationService.GetMarginTypeItems()).ToSelectList() }; return(this.View(model)); }
public async Task <IActionResult> GenerateBulkCoupons(BulkPromotionViewModel model) { string charSets = string.Empty; if (model.Characters) { charSets = charSets + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } if (model.Numbers) { charSets = charSets + "0123456789"; } if (!model.Characters && !model.Numbers) { charSets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; } List <PromotionViewModel> models = new List <PromotionViewModel>(); if (model.NoOfCoupons > 0) { var promoItem = (await this.cancellationService.GetMarginTypeItems()).ToSelectList().Where(x => x.Value == model.DiscountType.ToString()).FirstOrDefault(); for (int i = 0; i < model.NoOfCoupons; i++) { string couponCode = model.Preffix.ToUpper() + "-" + this.RandomString(4, charSets) + "-" + model.Postfix.ToString(); PromotionViewModel subModel = new PromotionViewModel { Id = 0, CouponCode = couponCode, DiscountType = model.DiscountType, DiscountValue = model.DiscountValue, IsActive = true, IsDeleted = false, MaxCount = model.MaxCount, MaxDiscountFlat = model.MaxDiscountFlat, Remark = "Bulk Coupon Generated on " + DateTime.Now.Date.ToString("dd/MM/yyyy"), ValidityStart = model.ValidityStart, ValidityEnd = model.ValidityEnd }; models.Add(subModel); } } return(this.PartialView(models)); }