Exemplo n.º 1
0
        //Daje se EditCardViewModelu preko konstruktora
        public async void OnEditCardCompleted(IEditable model)
        {
            if (model != null)
            {
                EditCard editCard = model as EditCard;
                if (editCard != null)
                {
                    if (ActiveUser.IsActive == true)
                    {
                        bool succ = await CardService.UpdateCard(ActiveUser.Instance.LoggedUser.Token, editCard.CardId, new UpdateCardDTO(editCard));

                        if (succ == true)
                        {
                            var readCard = CardList.Cards.FirstOrDefault(x => x.CardId == editCard.CardId);
                            ReadCard.UpdateCard(readCard, editCard);
                            InstantiatePanel(new CardViewModel(readCard, OnEditButtonClick));
                        }
                        else
                        {
                            ShowMessageBox(null, "Error updating card.");
                        }
                    }
                    else
                    {
                        ShowMessageBox(null, "Error getting user.");
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            EditCard ec = new EditCard(card);

            ec.DataUpdated += new EventHandler(EditCard_DataUpdated);
            ec.Show();
        }
Exemplo n.º 3
0
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            DependencyObject ptr = sender as DependencyObject;

            while (!(ptr is Custom_Card_SkillCard))
            {
                ptr = VisualTreeHelper.GetParent(ptr);
            }
            EditCard.Open_Edit((Custom_Card_SkillCard)ptr);
        }
 private void ContactsTable_OnItemClick(object sender, ItemClickEventArgs e)
 {
     if (e.ClickedItem != null)
     {
         EditCard edit = EditCardPanel;
         edit.DeleteVisible(true);
         var data = e.ClickedItem as ContactObject;
         if (data != null)
         {
             edit.Contact        = data;
             edit.AttachedFlyout = EditCardFlyout;
             DependencyObject container = ContactsTable.ContainerFromItem(data);
             EditCardFlyout.ShowAt(container as FrameworkElement);
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Edit and existing credit card and update CIM.
        /// </summary>
        /// <param name="creditcardid"></param>
        /// <returns></returns>
        public ActionResult EditCard(int creditcardid)
        {
            var card = new CreditCardEntity(creditcardid);

            if (card.IsNew)
            {
                throw new HttpException(404, SharedRes.Error.NotFound_CreditCard);
            }

            if (!Permissions.UserHasPermission("Edit", card))
            {
                throw new HttpException(401, SharedRes.Error.Unauthorized_CreditCard);
            }

            // populate the model with the card data loaded from authorize.net
            try
            {
                CustomerGateway cg;
                var             customer = RoleUtils.IsUserServiceAdmin()
                                   ? EnsureProfile(out cg, card.UserCreditCards.First().User)
                                   : EnsureProfile(out cg);

                var profile      = customer.PaymentProfiles.First(x => x.ProfileID == card.AuthorizeId);
                var addressLines = profile.BillingAddress.Street.Split('\n');
                var model        = new EditCard
                {
                    AddressLine1 = addressLines[0],
                    AddressLine2 = addressLines.Length > 1 ? addressLines[1] : "",
                    City         = profile.BillingAddress.City,
                    Country      = profile.BillingAddress.Country,
                    FirstName    = profile.BillingAddress.First,
                    LastName     = profile.BillingAddress.Last,
                    State        = profile.BillingAddress.State,
                    Zip          = profile.BillingAddress.Zip,
                };

                return(PartialView(model));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", Purchase.EditCard_Error);
                Log.Error(Purchase.EditCard_Error, ex);
            }

            return(PartialView());
        }
Exemplo n.º 6
0
        private void InitMessenger()
        {
            ServiceBus.Instance.Register <OpenMainMenuWindow>(
                this,
                msg =>
            {
                MainMenu mainmenu = new MainMenu();
                mainmenu.Show();
            });

            ServiceBus.Instance.Register <OpenStatisticsWindow>(
                this,
                msg =>
            {
                Statistics statWindow = new Statistics();
                statWindow.Show();
            });

            ServiceBus.Instance.Register <OpenViewCategoryWindow>(
                this,
                msg =>
            {
                Category category = new Category();
                category.Show();
            });

            ServiceBus.Instance.Register <OpenExamModeWindow>(
                this,
                msg =>
            {
                Prüfungsmodus examMode = new Prüfungsmodus();
                examMode.Show();
            });

            ServiceBus.Instance.Register <OpenLearnModeWindow>(
                this,
                msg =>
            {
                LearnMode learnmode = new LearnMode();

                learnmode.Show();
            });
            ServiceBus.Instance.Register <OpenExportWindow>(
                this,
                msg =>
            {
                Export export = new Export();
                export.Show();
            });
            ServiceBus.Instance.Register <OpenViewMarkedCardsWindow>(
                this,
                msg =>
            {
                ViewMarkedCards vmc = new ViewMarkedCards();
                vmc.Show();
            }

                );

            ServiceBus.Instance.Register <OpenCreateCardWindow>(
                this,
                msg =>
            {
                CreateCard createCardWindow = new CreateCard();
                createCardWindow.Show();
            });
            ServiceBus.Instance.Register <OpenEditCardWindow>(
                this,
                msg =>
            {
                EditCard editCard = new EditCard();
                editCard.Show();
            });

            ServiceBus.Instance.Register <OpenImportWindow>(
                this,
                msg =>
            {
                ImportExportXML importExportxml = new ImportExportXML();
                importExportxml.Show();
            });

            ServiceBus.Instance.Register <OpenCreateCategoryWindow>(
                this,
                msg =>
            {
                CreateCategory createCategory = new CreateCategory();
                createCategory.Show();
            });
        }
Exemplo n.º 7
0
        //public int UpdatedByUser { get; set; }

        public UpdateCardDTO(EditCard card)
        {
            Name        = card.Name;
            Description = card.Description;
            DueDate     = card.DueDate;
        }
Exemplo n.º 8
0
        //Daje se CardViewModelu preko konstruktora
        public void OnEditButtonClick(EditCard card)
        {
            var panel = new EditCardViewModel(OnEditCardCompleted, card);

            InstantiatePanel(panel);
        }
Exemplo n.º 9
0
        public ActionResult EditCard(int creditcardid, EditCard model)
        {
            var card = new CreditCardEntity(creditcardid);

            if (card.IsNew)
            {
                throw new HttpException(404, SharedRes.Error.NotFound_CreditCard);
            }

            if (!Permissions.UserHasPermission("Edit", card))
            {
                throw new HttpException(401, SharedRes.Error.Unauthorized_CreditCard);
            }

            if (ModelState.IsValid)
            {
                var transaction = new Transaction(IsolationLevel.ReadCommitted, "add card");
                try
                {
                    CustomerGateway cg;
                    var             customer = RoleUtils.IsUserServiceAdmin()
                                       ? EnsureProfile(out cg, card.UserCreditCards.First().User)
                                       : EnsureProfile(out cg);

                    var profile = customer.PaymentProfiles.First(x => x.ProfileID == card.AuthorizeId);

                    // update the card info
                    if (!string.IsNullOrEmpty(model.CardNumber))
                    {
                        profile.CardNumber     = model.CardNumber;
                        profile.CardCode       = model.SecurityCode;
                        profile.CardExpiration = model.CardMonth + "/" + model.CardYear;
                        card.AccountNumber     = model.CardNumber.Substring(model.CardNumber.Length - 4, 4);
                    }

                    // update the billing address
                    profile.BillingAddress = new AuthorizeNet.Address
                    {
                        First   = model.FirstName,
                        Last    = model.LastName,
                        Street  = model.AddressLine1 + Environment.NewLine + model.AddressLine2,
                        State   = model.State,
                        Country = model.Country,
                        City    = model.City,
                        Zip     = model.Zip
                    };
                    card.FirstName = model.FirstName;
                    card.LastName  = model.LastName;
                    card.Address   = model.AddressLine1;
                    transaction.Add(card);
                    card.Save();

                    cg.UpdatePaymentProfile(customer.ProfileID, profile);

                    transaction.Commit();
                    return(new EmptyResult());
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    ModelState.AddModelError("", Purchase.EditCard_Error);
                    Log.Error(Purchase.EditCard_Error, ex);
                }
                finally
                {
                    transaction.Dispose();
                }
            }

            Response.StatusCode             = 417;
            Response.TrySkipIisCustomErrors = true;

            return(PartialView(model));
        }
Exemplo n.º 10
0
 public EditCardViewModel(Action <IEditable> onExecute, EditCard card)
     : base(onExecute)
 {
     this.card = card;
 }