Exemple #1
0
        // GET: Shop/Edit/5
        public ActionResult Edit(int id)
        {
            Models.ShopModel shopModel = shopRepository.GetShopByID(id);

            var shopViewModel = new ShopEditViewModel();

            shopViewModel.Shop = shopModel;

            var        categories   = categoryRepository.GetAllCategories();
            SelectList categoryList = new SelectList(categories, "CategoryID", "Name");

            ViewData["CategoryList"] = categoryList;

            var address = addressRepository.GetAddressByID(shopModel.AddressID);

            shopViewModel.Address = address;

            var allPaymentMethods = paymentMethodsRepository.GetAllPaymentMethods();

            ViewData["AllPaymentMethods"] = allPaymentMethods;

            var shopPaymentMethods = paymentMethodsRepository.GetAllPaymentMethodsByShopId(shopModel.ShopId);

            List <PaymentMethodViewModel> paymentMethodViewModels = new List <PaymentMethodViewModel>();

            foreach (var paymentMethodModel in allPaymentMethods)
            {
                var paymentMethodViewModel = new PaymentMethodViewModel();
                paymentMethodViewModel.PaymentMethod = paymentMethodModel;

                foreach (var shopPaymentMethod in shopPaymentMethods)
                {
                    if (shopPaymentMethod.PaymentMethodID == paymentMethodModel.PaymentMethodID)
                    {
                        paymentMethodViewModel.Selected = true;
                    }
                }

                paymentMethodViewModels.Add(paymentMethodViewModel);
            }

            shopViewModel.PaymentMethods = paymentMethodViewModels;

            return(View("EditShop", shopViewModel));
        }
Exemple #2
0
        // GET: PaymentMethod
        public ActionResult Index()
        {
            List <Models.PaymentMethodModel> paymentMethods = paymentMethodRepository.GetAllPaymentMethods();

            return(View("Index", paymentMethods));
        }