public ActionResult Create() { if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageGiftCards)) return AccessDeniedView(); var model = new GiftCardModel(); model.PrimaryStoreCurrencyCode = _services.StoreContext.CurrentStore.PrimaryStoreCurrency.CurrencyCode; return View(model); }
public ActionResult Create(GiftCardModel model, bool continueEditing) { if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageGiftCards)) return AccessDeniedView(); if (ModelState.IsValid) { var giftCard = model.ToEntity(); giftCard.CreatedOnUtc = DateTime.UtcNow; _giftCardService.InsertGiftCard(giftCard); //activity log _customerActivityService.InsertActivity("AddNewGiftCard", _services.Localization.GetResource("ActivityLog.AddNewGiftCard"), giftCard.GiftCardCouponCode); NotifySuccess(_services.Localization.GetResource("Admin.GiftCards.Added")); return continueEditing ? RedirectToAction("Edit", new { id = giftCard.Id }) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form model.PrimaryStoreCurrencyCode = _services.StoreContext.CurrentStore.PrimaryStoreCurrency.CurrencyCode; return View(model); }
public ActionResult NotifyRecipient(GiftCardModel model) { if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageGiftCards)) return AccessDeniedView(); var giftCard = _giftCardService.GetGiftCardById(model.Id); model = giftCard.ToModel(); model.PurchasedWithOrderId = giftCard.PurchasedWithOrderItem != null ? (int?)giftCard.PurchasedWithOrderItem.OrderId : null; model.RemainingAmountStr = _priceFormatter.FormatPrice(giftCard.GetGiftCardRemainingAmount(), true, false); model.AmountStr = _priceFormatter.FormatPrice(giftCard.Amount, true, false); model.CreatedOn = _dateTimeHelper.ConvertToUserTime(giftCard.CreatedOnUtc, DateTimeKind.Utc); model.PrimaryStoreCurrencyCode = _services.StoreContext.CurrentStore.PrimaryStoreCurrency.CurrencyCode; try { if (!giftCard.RecipientEmail.IsEmail()) throw new SmartException("Recipient email is not valid"); if (!giftCard.SenderEmail.IsEmail()) throw new SmartException("Sender email is not valid"); var languageId = 0; var order = giftCard.PurchasedWithOrderItem != null ? giftCard.PurchasedWithOrderItem.Order : null; if (order != null) { var customerLang = _languageService.GetLanguageById(order.CustomerLanguageId); if (customerLang == null) customerLang = _languageService.GetAllLanguages().FirstOrDefault(); } else { languageId = _localizationSettings.DefaultAdminLanguageId; } int queuedEmailId = _workflowMessageService.SendGiftCardNotification(giftCard, languageId); if (queuedEmailId > 0) { giftCard.IsRecipientNotified = true; _giftCardService.UpdateGiftCard(giftCard); } } catch (Exception exc) { NotifyError(exc, false); } return View(model); }
public ActionResult Edit(GiftCardModel model, bool continueEditing) { if (!_services.Permissions.Authorize(StandardPermissionProvider.ManageGiftCards)) return AccessDeniedView(); var giftCard = _giftCardService.GetGiftCardById(model.Id); model.PurchasedWithOrderId = giftCard.PurchasedWithOrderItem != null ? (int?)giftCard.PurchasedWithOrderItem.OrderId : null; model.RemainingAmountStr = _priceFormatter.FormatPrice(giftCard.GetGiftCardRemainingAmount(), true, false); model.AmountStr = _priceFormatter.FormatPrice(giftCard.Amount, true, false); model.CreatedOn = _dateTimeHelper.ConvertToUserTime(giftCard.CreatedOnUtc, DateTimeKind.Utc); model.PrimaryStoreCurrencyCode = _services.StoreContext.CurrentStore.PrimaryStoreCurrency.CurrencyCode; if (ModelState.IsValid) { giftCard = model.ToEntity(giftCard); _giftCardService.UpdateGiftCard(giftCard); //activity log _customerActivityService.InsertActivity("EditGiftCard", _services.Localization.GetResource("ActivityLog.EditGiftCard"), giftCard.GiftCardCouponCode); NotifySuccess(_services.Localization.GetResource("Admin.GiftCards.Updated")); return continueEditing ? RedirectToAction("Edit", giftCard.Id) : RedirectToAction("List"); } //If we got this far, something failed, redisplay form return View(model); }
public ProductDetailsModel() { ProductVariantAttributes = new List <ProductVariantAttributeModel>(); GiftCard = new GiftCardModel(); Warnings = new List <string>(); }
public ProductDetailsModel() { ProductVariantAttributes = new List<ProductVariantAttributeModel>(); GiftCard = new GiftCardModel(); Warnings = new List<string>(); }
public ActionResult Create() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageGiftCards)) return AccessDeniedView(); var model = new GiftCardModel(); model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode; return View(model); }