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 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); }