public PaymentView(Payment payment) { ShopRepository shopRepository; BasketItemRepository basketItemRepository; IndividualRepository individualRepository; shopRepository = new ShopRepository(); individualRepository = new IndividualRepository(); basketItemRepository = new BasketItemRepository(); this.Id = payment.Id; this.isPayed = payment.isPayed; this.ShopId = payment.ShopId; if (this.ShopId != null) this.Shop = (Shop)shopRepository.FindById(this.ShopId); this.IndividualId = payment.IndividualId; if (this.IndividualId != null) this.Individual = (Individual) individualRepository.FindById(this.IndividualId); this.BasketItems = basketItemRepository.FindBasketItemsByPayment( this.Id); }
public BasketView(Basket basket) { IList<BasketItem> basketItems; IndividualRepository individualRepository; BasketItemRepository basketItemRepository; individualRepository = new IndividualRepository(); basketItemRepository = new BasketItemRepository(); this.Id = basket.Id; this.TotalAmount = basket.TotalAmount; this.DeliveryCost = basket.DeliveryCost; this.Individual = (Individual) individualRepository.FindById(this.Id); basketItems = basketItemRepository.FindAllByBasket(this.Id); this.BasketItemViews = (from basketItem in basketItems select new BasketItemView(basketItem)) .ToList<BasketItemView>(); }
public ActionResult SelectShop(Shop shop) { Basket basket; IList<Shop> shops; PaymentView paymentView; UrlGenerator urlGenerator; Payment payment, dbPayment; W1Payment w1Payment, dbW1Payment; W1PaymentView w1PaymentView; Individual individual; BasketService basketService; IndividualRepository individualRepository; PaymentRepository paymentRepository; PaymentService paymentService; //Необходимо вызвать UrlGenerator в любом Post-методе контроллера, //иначе Request и Url поля не будут доступны. //В будующем нужно исправить! urlGenerator = new UrlGenerator(this.Request, this.Url); basketService = new BasketService(); paymentRepository = new PaymentRepository(); paymentService = new PaymentService(); individualRepository = new IndividualRepository(); //---- shop = (Shop)this._shopRepository.FindById(shop.Id); //для адреса basket = basketService.GetBasket(User.Identity.Name); //Вычитаем заказанныек книги из BookVariableInfo и //обвновляем Basket basketService.ShopProcessing(basket, shop); shop.Address = (Address)this._addressRepository.FindById(shop.Id); //-- //Создание платежной формы W1Payment individual = (Individual)individualRepository .FindIndividualByUserProfileName(User.Identity.Name); w1Payment = new W1Payment(); w1Payment.WMI_PAYMENT_AMOUNT = paymentService.DecimalCounting( basket.TotalAmount, shop.BookDeliveryCost); w1Payment.WMI_DESCRIPTION = paymentService.MakeDescription(basket.Id); dbW1Payment = paymentService.MakeW1Payment(w1Payment); //добавление payment и w1Payment payment = new Payment() { Id = dbW1Payment.WMI_PAYMENT_NO, ShopId = shop.Id, IndividualId = individual.Id }; dbPayment = paymentService.AddPayment(payment, w1Payment); payment.Id = dbPayment.Id; //Перемещение заказов из корзины в платеж и очистка корзины basketService.BasketToPaymentMigration(basket, payment); //-Создали представление для отображения w1Payment и передачи его в POST w1PaymentView = new W1PaymentView(dbW1Payment);//payment, basket); return RedirectToAction("BasketPay", w1PaymentView);//shop); //payment); }