public ProductDetailsModel()
 {
     DefaultPictureModel = new PictureModel();
     PictureModels = new List<PictureModel>();
     GiftCard = new GiftCardModel();
     ProductPrice = new ProductPriceModel();
     AddToCart = new AddToCartModel();
     ProductVariantAttributes = new List<ProductVariantAttributeModel>();
     AssociatedProducts = new List<ProductDetailsModel>();
 }
 public ProductDetailsModel()
 {
     Manufacturers = new List<ManufacturerOverviewModel>();
     GiftCard = new GiftCardModel();
     ProductPrice = new ProductPriceModel();
     AddToCart = new AddToCartModel();
     ProductVariantAttributes = new List<ProductVariantAttributeModel>();
     AssociatedProducts = new List<ProductDetailsModel>();
     BundledItems = new List<ProductDetailsModel>();
     BundleItem = new ProductBundleItemModel();
     IsAvailable = true;
 }
 public ProductDetailsModel()
 {
     //codehint: sm-edit
     //Manufacturers = new List<ProductManufacturer>();
     Manufacturers = new List<ManufacturerOverviewModel>();
     GiftCard = new GiftCardModel();
     ProductPrice = new ProductPriceModel();
     AddToCart = new AddToCartModel();
     ProductVariantAttributes = new List<ProductVariantAttributeModel>();
     Combinations = new List<ProductVariantAttributeCombination>();
     AssociatedProducts = new List<ProductDetailsModel>();
     BundledItems = new List<ProductDetailsModel>();
     BundleItem = new ProductBundleItemModel();
     IsAvailable = true;
 }
 public ProductDetailsModel()
 {
     DefaultPictureModel = new PictureModel();
     PictureModels = new List<PictureModel>();
     GiftCard = new GiftCardModel();
     ProductPrice = new ProductPriceModel();
     AddToCart = new AddToCartModel();
     ProductAttributes = new List<ProductAttributeModel>();
     AssociatedProducts = new List<ProductDetailsModel>();
     VendorModel = new VendorBriefInfoModel();
     Breadcrumb = new ProductBreadcrumbModel();
     ProductTags = new List<ProductTagModel>();
     ProductSpecifications= new List<ProductSpecificationModel>();
     ProductManufacturers = new List<ManufacturerModel>();
     ProductReviewOverview = new ProductReviewOverviewModel();
     TierPrices = new List<TierPriceModel>();
 }
示例#5
0
        public ActionResult NotifyRecipient(GiftCardModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGiftCards))
            {
                return(AccessDeniedView());
            }

            var giftCard = _giftCardService.GetGiftCardById(model.Id);

            model = giftCard.ToModel();
            model.PurchasedWithOrderId     = giftCard.PurchasedWithOrderProductVariant != null ? (int?)giftCard.PurchasedWithOrderProductVariant.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 = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;

            try
            {
                if (!CommonHelper.IsValidEmail(giftCard.RecipientEmail))
                {
                    throw new NopException("Recipient email is not valid");
                }
                if (!CommonHelper.IsValidEmail(giftCard.SenderEmail))
                {
                    throw new NopException("Sender email is not valid");
                }

                int queuedEmailId = _workflowMessageService.SendGiftCardNotification(giftCard, _localizationSettings.DefaultAdminLanguageId);
                if (queuedEmailId > 0)
                {
                    giftCard.IsRecipientNotified = true;
                    _giftCardService.UpdateGiftCard(giftCard);
                }
            }
            catch (Exception exc)
            {
                ErrorNotification(exc, false);
            }

            return(View(model));
        }
示例#6
0
        public ActionResult Edit(GiftCardModel model, bool continueEditing)
        {
            if (!_permissionService.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 = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;

            if (ModelState.IsValid)
            {
                giftCard = model.ToEntity(giftCard);
                _giftCardService.UpdateGiftCard(giftCard);

                //activity log
                _customerActivityService.InsertActivity("EditGiftCard", _localizationService.GetResource("ActivityLog.EditGiftCard"), giftCard.GiftCardCouponCode);

                SuccessNotification(_localizationService.GetResource("Admin.GiftCards.Updated"));

                if (continueEditing)
                {
                    //selected tab
                    SaveSelectedTabIndex();

                    return(RedirectToAction("Edit", giftCard.Id));
                }
                else
                {
                    return(RedirectToAction("List"));
                }
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#7
0
        /// <summary>
        /// Prepare gift card model
        /// </summary>
        /// <param name="model">Gift card model</param>
        /// <param name="giftCard">Gift card</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Gift card model</returns>
        public virtual GiftCardModel PrepareGiftCardModel(GiftCardModel model, GiftCard giftCard, bool excludeProperties = false)
        {
            if (giftCard != null)
            {
                //fill in model values from the entity
                model = model ?? giftCard.ToModel();

                model.PurchasedWithOrderId     = giftCard.PurchasedWithOrderItem?.OrderId;
                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.PurchasedWithOrderNumber = giftCard.PurchasedWithOrderItem?.Order?.CustomOrderNumber;

                //prepare nested search model
                PrepareGiftCardUsageHistorySearchModel(model.GiftCardUsageHistorySearchModel, giftCard);
            }

            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)?.CurrencyCode;

            return(model);
        }
示例#8
0
        public ActionResult Create(GiftCardModel model, bool continueEditing)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGiftCards))
                return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var giftCard = model.ToEntity();
                giftCard.CreatedOnUtc = DateTime.UtcNow;
                _giftCardService.InsertGiftCard(giftCard);

                //activity log
                _customerActivityService.InsertActivity("AddNewGiftCard", _localizationService.GetResource("ActivityLog.AddNewGiftCard"), giftCard.GiftCardCouponCode);

                SuccessNotification(_localizationService.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 = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            return View(model);
        }
示例#9
0
        public virtual async Task <Order> FillGiftCardModel(GiftCard giftCard, GiftCardModel model)
        {
            Order order = null;

            if (giftCard.PurchasedWithOrderItem != null)
            {
                order = await _orderService.GetOrderByOrderItemId(giftCard.PurchasedWithOrderItem.Id);
            }

            var currency = await _currencyService.GetCurrencyByCode(giftCard.CurrencyCode);

            if (currency == null)
            {
                currency = await _currencyService.GetPrimaryStoreCurrency();
            }

            model.PurchasedWithOrderId = giftCard.PurchasedWithOrderItem != null ? order.Id : null;
            model.RemainingAmountStr   = _priceFormatter.FormatPrice(giftCard.GetGiftCardRemainingAmount(), true, currency, _workContext.WorkingLanguage, true, false);
            model.AmountStr            = _priceFormatter.FormatPrice(giftCard.Amount, true, currency, _workContext.WorkingLanguage, true, false);
            model.CreatedOn            = _dateTimeHelper.ConvertToUserTime(giftCard.CreatedOnUtc, DateTimeKind.Utc);
            model.CurrencyCode         = giftCard.CurrencyCode;
            return(order);
        }
示例#10
0
 public ProductDetailsModel()
 {
     ProductAttributes = new List<ProductAttributeModel>();
     GiftCard = new GiftCardModel();
     Warnings = new List<string>();
 }
        public virtual IActionResult NotifyRecipient(GiftCardModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGiftCards))
            {
                return(AccessDeniedView());
            }

            //try to get a gift card with the specified id
            var giftCard = _giftCardService.GetGiftCardById(model.Id);

            if (giftCard == null)
            {
                return(RedirectToAction("List"));
            }

            model = giftCard.ToModel(model);
            model.PurchasedWithOrderId     = giftCard.PurchasedWithOrderItem != null ? (int?)giftCard.PurchasedWithOrderItem.OrderId : null;
            model.RemainingAmountStr       = _priceFormatter.FormatPrice(_giftCardService.GetGiftCardRemainingAmount(giftCard), true, false);
            model.AmountStr                = _priceFormatter.FormatPrice(giftCard.Amount, true, false);
            model.CreatedOn                = _dateTimeHelper.ConvertToUserTime(giftCard.CreatedOnUtc, DateTimeKind.Utc);
            model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
            model.PurchasedWithOrderNumber = giftCard.PurchasedWithOrderItem?.Order.CustomOrderNumber;

            try
            {
                if (!CommonHelper.IsValidEmail(giftCard.RecipientEmail))
                {
                    throw new NopException("Recipient email is not valid");
                }

                if (!CommonHelper.IsValidEmail(giftCard.SenderEmail))
                {
                    throw new NopException("Sender email is not valid");
                }

                var languageId = 0;
                var order      = giftCard.PurchasedWithOrderItem?.Order;
                if (order != null)
                {
                    var customerLang = _languageService.GetLanguageById(order.CustomerLanguageId);
                    if (customerLang == null)
                    {
                        customerLang = _languageService.GetAllLanguages().FirstOrDefault();
                    }
                    if (customerLang != null)
                    {
                        languageId = customerLang.Id;
                    }
                }
                else
                {
                    languageId = _localizationSettings.DefaultAdminLanguageId;
                }

                var queuedEmailIds = _workflowMessageService.SendGiftCardNotification(giftCard, languageId);
                if (queuedEmailIds.Any())
                {
                    giftCard.IsRecipientNotified = true;
                    _giftCardService.UpdateGiftCard(giftCard);
                    model.IsRecipientNotified = true;
                }
            }
            catch (Exception exc)
            {
                ErrorNotification(exc, false);
            }

            return(View(model));
        }
示例#12
0
 public static GiftCard ToEntity(this GiftCardModel model, GiftCard destination)
 {
     return(Mapper.Map(model, destination));
 }
示例#13
0
 public static GiftCard ToEntity(this GiftCardModel model)
 {
     return(Mapper.Map <GiftCardModel, GiftCard>(model));
 }
示例#14
0
 public ProductVariantModel()
 {
     GiftCard = new GiftCardModel();
     ProductVariantPrice = new ProductVariantPriceModel();
     PictureModel = new PictureModel();
     AddToCart = new AddToCartModel();
     ProductVariantAttributes = new List<ProductVariantAttributeModel>();
 }
示例#15
0
 public ProductDetailsModel()
 {
     ProductAttributes = new List <ProductAttributeModel>();
     GiftCard          = new GiftCardModel();
     Warnings          = new List <string>();
 }
示例#16
0
 private void onStarScanGiftCadrEvent(string param)
 {
     if (string.IsNullOrEmpty(Barcode) || Barcode.Trim().ToString() == "")
     {
         Barcode      = "";
         StringNotify = App.Current.FindResource("barcode_null").ToString();
         OnFocusRequested(nameof(Barcode));
     }
     else if (Barcode.Trim() == "0")
     {
         ShellOutViewModel.eventFillValueGiftCard("0:0", null);
         //ShellOutViewModel.eventResetListboxSelected(null, null);
         OnFocusRequested(nameof(Barcode));
         OnRequestClose();
     }
     else
     {
         DataTable _gift = GiftCardModel.getGiftCardByBarcode(Barcode.Trim());
         if (_gift.Rows.Count == 0)
         {
             StringNotify = App.Current.FindResource("giftcard_not_existing").ToString();
         }
         else
         {
             bool  _isError      = false;
             Int32 unixTimestamp = getCurrentUnixTime();
             Int32 _expreTime    = Convert.ToInt32(_gift.Rows[0]["ExpirationDate"]);
             if (unixTimestamp > _expreTime)
             {
                 StringNotify = App.Current.FindResource("giftcard_expired").ToString();
                 OnFocusRequested(nameof(Barcode));
                 _isError = true;
             }
             else if (Convert.ToDouble(_gift.Rows[0]["Balance"]) <= 0)
             {
                 StringNotify = App.Current.FindResource("giftcard_in_used").ToString();
                 OnFocusRequested(nameof(Barcode));
                 _isError = true;
             }
             else if (Convert.ToInt32(_gift.Rows[0]["GiftCardID"].ToString()) != ScanGiftId)
             {
                 if (allReadyExits(StaticClass.GeneralClass.customerGiftCard, _gift.Rows[0]["GiftCardID"].ToString()))
                 {
                     StringNotify = App.Current.FindResource("acard_isnot_multiple").ToString();
                     OnFocusRequested(nameof(Barcode));
                     _isError = true;
                 }
             }
             else if (!_isError && StaticClass.GeneralClass.ConverStringToDecimal(UseValue) <= 0)
             {
                 StringNotify = App.Current.FindResource("enter_amount_want").ToString();
                 OnFocusRequested(nameof(UseValue));
                 _isError = true;
             }
             else if (!_isError && Convert.ToDecimal(_gift.Rows[0]["Balance"]) < StaticClass.GeneralClass.ConverStringToDecimal(UseValue))
             {
                 StringNotify = App.Current.FindResource("value_invalid").ToString();
                 OnFocusRequested(nameof(UseValue));
                 _isError = true;
             }
             if (!_isError)
             {
                 if (Convert.ToInt32(_gift.Rows[0]["GiftCardID"].ToString()) != ScanGiftId)
                 {
                     StaticClass.GeneralClass.customerGiftCard.Remove(ScanGiftId);
                     StaticClass.GeneralClass.customerGiftCard.Add(Convert.ToInt32(_gift.Rows[0]["GiftCardID"].ToString()));
                 }
                 ShellOutViewModel.eventFillValueGiftCard(_gift.Rows[0]["GiftCardID"].ToString() + ":" + UseValue, null);
                 //ShellOutViewModel.eventResetListboxSelected(null, null);
                 OnRequestClose();
             }
         }
     }
 }
        public virtual IActionResult NotifyRecipient(GiftCardModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageGiftCards))
            {
                return(AccessDeniedView());
            }

            //try to get a gift card with the specified id
            var giftCard = _giftCardService.GetGiftCardById(model.Id);

            if (giftCard == null)
            {
                return(RedirectToAction("List"));
            }

            try
            {
                if (!CommonHelper.IsValidEmail(giftCard.RecipientEmail))
                {
                    throw new NopException("Recipient email is not valid");
                }

                if (!CommonHelper.IsValidEmail(giftCard.SenderEmail))
                {
                    throw new NopException("Sender email is not valid");
                }

                var languageId = 0;
                var order      = _orderService.GetOrderByOrderItem(giftCard.PurchasedWithOrderItemId ?? 0);

                if (order != null)
                {
                    var customerLang = _languageService.GetLanguageById(order.CustomerLanguageId);
                    if (customerLang == null)
                    {
                        customerLang = _languageService.GetAllLanguages().FirstOrDefault();
                    }
                    if (customerLang != null)
                    {
                        languageId = customerLang.Id;
                    }
                }
                else
                {
                    languageId = _localizationSettings.DefaultAdminLanguageId;
                }

                var queuedEmailIds = _workflowMessageService.SendGiftCardNotification(giftCard, languageId);
                if (queuedEmailIds.Any())
                {
                    giftCard.IsRecipientNotified = true;
                    _giftCardService.UpdateGiftCard(giftCard);
                    model.IsRecipientNotified = true;
                }
            }
            catch (Exception exc)
            {
                _notificationService.ErrorNotification(exc);
            }

            //prepare model
            model = _giftCardModelFactory.PrepareGiftCardModel(model, giftCard);

            return(View(model));
        }
示例#18
0
 public virtual async Task <GiftCardModel> PrepareGiftCardModel(GiftCardModel model)
 {
     model.PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode;
     return(model);
 }
 public virtual GiftCardModel PrepareGiftCardModel(GiftCardModel model)
 {
     model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode;
     return(model);
 }
 public static GiftCard ToEntity(this GiftCardModel model)
 {
     return(model.MapTo <GiftCardModel, GiftCard>());
 }
示例#21
0
        private void onPagingClick(string _param)
        {
            if (_param == PageOptions.First.ToString())
            {
                paging.CurrentPage = 1;
                ShowNextPage       = true;
                ShowLastPage       = true;
                ShowFirstPage      = false;
                ShowPrevPage       = false;
            }
            else if (_param == PageOptions.Last.ToString())
            {
                paging.CurrentPage = paging.MaxPage;
                ShowNextPage       = false;
                ShowLastPage       = false;
                ShowFirstPage      = true;
                ShowPrevPage       = true;
            }
            else if (_param == PageOptions.Previous.ToString())
            {
                if (paging.CurrentPage == 1)
                {
                    ShowNextPage  = true;
                    ShowLastPage  = true;
                    ShowFirstPage = false;
                    ShowPrevPage  = false;
                }
                else
                {
                    paging.CurrentPage--;
                    ShowNextPage  = true;
                    ShowLastPage  = true;
                    ShowFirstPage = true;
                    ShowPrevPage  = true;
                }
            }
            else if (_param == PageOptions.Next.ToString())
            {
                if (paging.CurrentPage == paging.MaxPage)
                {
                    ShowNextPage  = false;
                    ShowLastPage  = false;
                    ShowFirstPage = true;
                    ShowPrevPage  = true;
                }
                else
                {
                    paging.CurrentPage++;
                    ShowNextPage  = true;
                    ShowLastPage  = true;
                    ShowFirstPage = true;
                    ShowPrevPage  = true;
                }
            }
            ShowCurPage = paging.CurrentPage;
            GiftCard.Clear();
            DataTable GiftCards = GiftCardModel.advanceSearchGiftCardByMultiCondition(this._txtKeySearch, paging.StringLimit, this._txtSortBy);

            if (GiftCards.Rows.Count > 0)
            {
                var i = 1;
                foreach (DataRow dr in GiftCards.Rows)
                {
                    DateTime dt         = UnixTimeToDateTime(Convert.ToInt32(dr["CreateDate"]));
                    DateTime _expreTime = UnixTimeToDateTime(Convert.ToInt32(dr["ExpirationDate"].ToString()));
                    string   _delivered = string.Empty;
                    if (Convert.ToInt32(dr["DeliveredDate"]) > 0)
                    {
                        DateTime _timeDeliver = UnixTimeToDateTime(Convert.ToInt32(dr["DeliveredDate"].ToString()));
                        _delivered = _timeDeliver.ToString(_orderDate);
                    }
                    string _customName = string.IsNullOrEmpty(dr["FullName"].ToString())? "None": dr["FullName"].ToString();
                    GiftCard.Add(new GiftCardModel {
                        No = i, GiftCardID = Convert.ToInt32(dr["GiftCardID"].ToString()), Barcode = dr["Barcode"].ToString(), Serial = dr["Serial"].ToString(), CreateDate = dt.ToString(_orderDate), ExpirationDate = _expreTime.ToString(_orderDate), CustomerIDUse = Convert.ToInt32(dr["CustomerIDUse"].ToString()), Amount = Convert.ToDouble(dr["Amount"].ToString()), Balance = Convert.ToDouble(dr["Balance"].ToString()), IsChecked = false, CustomerName = _customName, DeliveredDate = _delivered
                    });
                    i++;
                }
            }
            IsCheckAll = false;
        }
示例#22
0
 public static GiftCard ToEntity(this GiftCardModel model, GiftCard entity)
 {
     MapperFactory.Map(model, entity);
     return(entity);
 }
示例#23
0
        private void InitGiftCard()
        {
            GiftCard.Clear();
            DataTable GiftCards = GiftCardModel.advanceSearchGiftCardByMultiCondition(this._txtKeySearch, paging.StringLimit, this._txtSortBy);

            if (GiftCards.Rows.Count == 0 && paging.CurrentPage > 1)
            {
                paging.CurrentPage = paging.CurrentPage - 1;
                GiftCards          = GiftCardModel.advanceSearchGiftCardByMultiCondition(this._txtKeySearch, paging.StringLimit, this._txtSortBy);
                ShowCurPage        = paging.CurrentPage;
            }
            if (GiftCards.Rows.Count > 0)
            {
                var i = 1;
                foreach (DataRow dr in GiftCards.Rows)
                {
                    DateTime dt           = UnixTimeToDateTime(Convert.ToInt32(dr["CreateDate"]));
                    DateTime _expreTime   = UnixTimeToDateTime(Convert.ToInt32(dr["ExpirationDate"].ToString()));
                    string   _giftCardImg = GiftCardModel.GiftCardImgPath + dr["Barcode"].ToString() + ".png";
                    string   _deliverDate = string.Empty;
                    if (Convert.ToInt32(dr["DeliveredDate"].ToString()) > 0)
                    {
                        DateTime _isDelivered = UnixTimeToDateTime(Convert.ToInt32(dr["DeliveredDate"].ToString()));
                        _deliverDate = _isDelivered.ToString(StaticClass.GeneralClass.dateFromatSettings[StaticClass.GeneralClass.app_settings["dateFormat"]].ToString() + _orderTime);
                    }
                    GiftCard.Add(new GiftCardModel {
                        No = i, GiftCardID = Convert.ToInt32(dr["GiftCardID"].ToString()), Barcode = dr["Barcode"].ToString(), Serial = dr["Serial"].ToString(), CreateDate = dt.ToString(StaticClass.GeneralClass.dateFromatSettings[StaticClass.GeneralClass.app_settings["dateFormat"]].ToString() + _orderTime), ExpirationDate = _expreTime.ToString(StaticClass.GeneralClass.dateFromatSettings[StaticClass.GeneralClass.app_settings["dateFormat"]].ToString() + _orderTime), CustomerIDUse = Convert.ToInt32(dr["CustomerIDUse"].ToString()), Amount = Convert.ToDouble(dr["Amount"].ToString()), Balance = Convert.ToDouble(dr["Balance"].ToString()), IsChecked = false, CustomerName = string.IsNullOrEmpty(dr["FullName"].ToString())?"None": dr["FullName"].ToString(), DeliveredDate = _deliverDate
                    });
                    i++;
                }
            }
            if (GiftCards.Rows.Count == 0 || (paging.CurrentPage == 1 && paging.MaxPage == 1))
            {
                ShowNextPage  = false;
                ShowLastPage  = false;
                ShowFirstPage = false;
                ShowPrevPage  = false;
                IsPaging      = "Hidden";

                /*if (GiftCards.Rows.Count == 0)
                 * {
                 *  ModernDialog md = new ModernDialog();
                 *  md.CloseButton.FindResource("close").ToString();
                 *  md.Content = App.Current.FindResource("cannot_found_data").ToString();
                 *  md.Title = App.Current.FindResource("notification").ToString();
                 *  md.ShowDialog();
                 * }*/
            }
            else if (paging.CurrentPage == paging.MaxPage)
            {
                ShowNextPage  = false;
                ShowLastPage  = false;
                ShowFirstPage = true;
                ShowPrevPage  = true;
            }
            else if (paging.MaxPage > 1)
            {
                IsPaging     = "Visible";
                ShowNextPage = true;
                ShowLastPage = true;
            }
            IsCheckAll = false;
        }
 public static GiftCard ToEntity(this GiftCardModel model, GiftCard destination)
 {
     return(model.MapTo(destination));
 }
示例#25
0
        private async void DisplayQrCode(GiftCardModel GiftCardModel)
        {
            if (IsBusy || IsLoading)
            {
                // message toast
                ShowSnackBarWithAction(TranslateManagerHelper.Convert("loading_please_wait"), null, TranslateManagerHelper.Convert("ok").ToUpperInvariant());
                return;
            }
            IsLoading = true;

            QRCodeGiftKardData obj = JsonConvert.DeserializeObject <QRCodeGiftKardData>(GiftCardModel.QRCodeData);

            obj.Number = GiftCardModel.GiftCardNumber;
            obj.Amount = GiftCardModel.Amount;

            // call genreate qrcode service
            var qrcodedata = new QRcodeRequest();

            qrcodedata.Type       = "Text";
            qrcodedata.Separator  = string.Empty;
            qrcodedata.Parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("QRCodeData", JsonConvert.SerializeObject(obj))
            };

            /*
             * Call Simple API here
             */
            var qc = await _qRCode.Generate <QRcodeRequest>(_authentication.GetToken(), qrcodedata);

            if (qc == null || qc?.isuccess == false)
            {
                string message = "";
                switch (qc?.errcode)
                {
                case "EXCEPTION":
                    TranslateManagerHelper.Convert("error_occured");
                    break;

                default:
                    message = !string.IsNullOrEmpty(qc?.msg) ? qc.msg : TranslateManagerHelper.Convert("qrcode_error_occured");
                    break;
                }

                var parameters = new NavigationParameters
                {
                    { Constants.PopupIsSucces, false },
                    { Constants.PopupMessage, message },
                    { Constants.PopupIsBeforeHome, false },
                    { Constants.PopupNextPage, "" }
                };
                await NavigationService.NavigateAsync(PopupName.SuccessfullPopup, parameters).ConfigureAwait(false);

                IsLoading = false;
                return;
            }

            var qrImage = Xamarin.Forms.ImageSource.FromStream(
                () => new MemoryStream(Convert.FromBase64String(qc.data)));

            var data = new DisplayQrCodeModel()
            {
                Code1 = GiftCardModel.GiftCardNumber,
                //Code2 = GiftCardModel.Amount,
                //Currency = obj.Currency,
                IsDisplayIcon = false,
                QrCodeImage   = qrImage,
                Title         = TranslateManagerHelper.Convert("scan_me"),
                HigthTitle    = TranslateManagerHelper.Convert("gift_card"),
                CompanyId     = obj.CompanyId,
                CompanyName   = obj.CompanyName
            };

            var Parameters = new NavigationParameters()
            {
                { Constants.QrCodeId, "DISPLAY_QRCODE" },
                { Constants.QrCodeResponseData, data }
            };

            await NavigationService.NavigateAsync(FunctionName.GenerateQrCode, Parameters);

            IsLoading = false;
        }