Beispiel #1
0
        public ActionResult CompletePurchase(BuyViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("SelectItems"));
            }

            var invoice     = Context.Invoices.SingleOrDefault(i => i.ReservationId == viewModel.ReservationId);
            var reservation = Context.Reservations.SingleOrDefault(r => r.Id == viewModel.ReservationId);

            var invoiceId = invoice.Id;

            var item = new Item
            {
                InvoiceId        = invoiceId,
                ServiceProductId = viewModel.ServiceProductId,
                Quantity         = viewModel.Quantity
            };

            invoice.IsPaid = false;
            reservation.ReservationStatusId = 2;
            Context.Items.Add(item);

            try
            {
                Context.SaveChanges();
                return(RedirectToAction("ShopList"));
            }
            catch (Exception e)
            {
                Logger.Error(e, e.Message);
                return(View("Error", new HandleErrorInfo(e, "Shop", "CompletePurchase")));
            }
        }
Beispiel #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            PriceService priceService = new PriceService();

            int currentMinute = 10;

            CreateCommand <BuyViewModel> createCalculatePriceCommand;
            CreateCommand <BuyViewModel> createBuyCommand;

            if (currentMinute % 2 == 1)
            {
                createCalculatePriceCommand = (vm) => new CalculatePriceCommand(vm, priceService);
                createBuyCommand            = (vm) => new BuyCommand(vm, priceService);
            }
            else
            {
                CreateCommand <BuyViewModel> createStoreClosedCommand = (vm) => new StoreClosedCommand(vm);

                createCalculatePriceCommand = createStoreClosedCommand;
                createBuyCommand            = createStoreClosedCommand;
            }

            BuyViewModel initialViewModel = new BuyViewModel(createCalculatePriceCommand, createBuyCommand);

            MainWindow = new MainWindow()
            {
                DataContext = initialViewModel
            };

            MainWindow.Show();

            base.OnStartup(e);
        }
Beispiel #3
0
        public IActionResult Buy(BuyViewModel viewModel)
        {
            string userEmail = _httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);

            _transactionApplicationService.Buy(userEmail, viewModel);
            return(Ok());
        }
        public ActionResult Buy(BuyViewModel vm)
        {
            if (vm.Amount <= 0 || vm.Amount > vm.Limit || vm == null || !this.ModelState.IsValid)
            {
                return View("TradeError");
            }

            Books targeBook = BookProviders.Instance.AllBooks.SingleOrDefault(b => b.Id == vm.BookId);
            User targeUser = UserProvider.Instance.AllUser.SingleOrDefault(u => u.Id == vm.UserId);
            if (targeUser == null || targeBook == null)
            {
                return View("TradeError");
            }

            Order order = new Order();
            order.ID = (new Random()).Next(1, 10000);
            order.BookId = vm.BookId;
            order.UserId = vm.UserId;
            order.Total = (double)targeBook.Price * vm.Amount;

            OrderViewModel orderViewModel = new OrderViewModel();
            orderViewModel.Order = order;
            orderViewModel.Book = targeBook;
            orderViewModel.User = targeUser;

            return View("Order", orderViewModel);
        }
Beispiel #5
0
        public IHttpActionResult PostSaveBuy(BuyViewModel b)
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
            con.Open();
            SqlCommand cmd1 = new SqlCommand("SP_SaveBuy", con);

            cmd1.CommandType = CommandType.StoredProcedure;
            cmd1.Parameters.AddWithValue("@UserId", b.UserId);
            cmd1.Parameters.AddWithValue("@CoinTypeId", b.CoinTypeId);
            cmd1.Parameters.AddWithValue("@DestinationofBitCoins", "XXX");
            cmd1.Parameters.AddWithValue("@Amount_In_USD", b.AmtInUSD);
            cmd1.Parameters.AddWithValue("@Amount_In_Coins", b.AmtInCoins);
            cmd1.Parameters.AddWithValue("@Fee", b.Fee);
            cmd1.Parameters.AddWithValue("@Tax", b.Tax);
            cmd1.Parameters.AddWithValue("@Total", b.Total);
            cmd1.Parameters.AddWithValue("@PaymentTYpe", "xxx");
            cmd1.Parameters.AddWithValue("@Insert_Date", System.DateTime.Now);

            int Result = cmd1.ExecuteNonQuery();

            con.Close();
            //int res=con.savaC();
            // if(res>0)
            if (Result != 0)
            {
                return(Ok("Buy Amount Saved Successfully"));
            }
            else
            {
                return(BadRequest("Record not saved , Try again.."));
            }
        }
Beispiel #6
0
        public BuyCommand(BuyViewModel viewModel, IOwnedItemsStore ownedItemsStore)
        {
            _viewModel       = viewModel;
            _ownedItemsStore = ownedItemsStore;

            _viewModel.PropertyChanged += ViewModel_PropertyChanged;
        }
        public ActionResult Create()
        {
            var empty = new BuyViewModel();
            var data  = empty.ToVM();

            return(View(data));
        }
Beispiel #8
0
        public BuyCommand(BuyViewModel viewModel, PriceService priceService)
        {
            _viewModel    = viewModel;
            _priceService = priceService;

            _viewModel.PropertyChanged += ViewModel_PropertyChanged;
        }
Beispiel #9
0
        public BuyViewModel GetBuyById(int id)
        {
            var dbBuys = _buyRepository.GetById(id);

            var buyViewModel = new BuyViewModel()
            {
                FullName             = dbBuys.User.FirstName + " " + dbBuys.User.LastName,
                Address              = dbBuys.User.Address,
                Contact              = dbBuys.User.PhoneNumber,
                IsSuccessfullyBuying = dbBuys.IsSuccessfullyBuying,
                Price   = dbBuys.Price,
                Tickets = new List <TicketViewModel>(),
            };

            foreach (var ticket in dbBuys.Tickets)
            {
                var tempTicket = new TicketViewModel()
                {
                    MatchName = ticket.MatchName,
                    Price     = ticket.Price,
                    Sector    = ticket.Sector
                };

                buyViewModel.Tickets.Add(tempTicket);
            }

            return(buyViewModel);
        }
Beispiel #10
0
        public async Task <IActionResult> Buy(BuyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var listing = _context.BookListings.Where(a => a.ID == model.listingId).FirstOrDefault();

            if (listing != null)
            {
                var user = await GetCurrentUserAsync();

                var newLog = new TransactionLog(listing.ApplicationUserID, user.Id, listing.BookID, 0, 1, listing.AskingPrice, listing.Condition, DateTime.Now);
                _context.Add(newLog);
                await _context.SaveChangesAsync();

                // Send email notification to User that is selling book.\
                var contact = "Phone: " + user.PhoneNumber;
                if (user.PreferredContact.Equals("Email"))
                {
                    contact = "Email: " + user.Email;
                }
                var seller = await _userManager.FindByIdAsync(listing.ApplicationUserID);

                var book = _context.Books.Where(a => a.ID == listing.BookID).FirstOrDefault();
                await _emailSender.SendEmailAsync(seller.Email, "NYBE Book Interest",
                                                  $"User <b>{user.FirstName} {user.LastName}</b> is interested in <b>{book.Title}</b> that you have for sale!  They should be contacting you shortly, however feel free to contact them by <b>{contact}</b>.");
            }
            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
Beispiel #11
0
        public ActionResult Buy(BuyViewModel BuyVM)
        {
            ViewBag.ErrMessage = "";

            string pId = Colors.RandomString(18);

            // find the product that being sold
            var product = db.Products.Find(BuyVM.ProductId);

            // create an object of Purchase nad set the fields
            var purchase = new Purchase();

            purchase.Payment      = BuyVM.Payment;
            purchase.Product      = product;
            purchase.PurchaseDate = DateTime.Now;
            purchase.PurchaseId   = pId;

            // check if purchase is from a user
            ApplicationUser currentUser = null;

            if (User.Identity.IsAuthenticated)
            {
                string id = User.Identity.GetUserId();
                currentUser = db.Users.FirstOrDefault(x => x.Id == id);
            }
            purchase.User = currentUser;

            // start the shipping process for the purchase
            Shipping shipping = new Shipping();

            shipping.address      = BuyVM.address;
            shipping.Purchase     = purchase;
            shipping.ShippingDate = DateTime.Now.AddDays(3);

            // check for quantity and inventory
            if (BuyVM.PurchaseQuantity < 0)
            {
                TempData["ErrMessage"] = "Quantity must be between 1 to 10 units";
                return(RedirectToAction("Buy", "Products", new { id = product.ProductId }));
            }



            if ((product.Quantity - BuyVM.PurchaseQuantity) < 0)
            {
                TempData["ErrMessage"] = "Short in Inventory! Maximun quantity: " + product.Quantity;
                return(RedirectToAction("Buy", "Products", new { id = product.ProductId }));
            }
            product.Quantity -= BuyVM.PurchaseQuantity;

            db.Purchases.Add(purchase);
            db.Shippings.Add(shipping);
            db.Entry(product).State = EntityState.Modified;
            db.SaveChanges();

            //return View("AllProducts", db.Products.ToList());
            TempData["SuccessMessage"] = "your Purchase Number is: " + purchase.PurchaseId;
            return(RedirectToAction("Index"));
        }
        public BuyReport()
        {
            InitializeComponent();
            BuyViewModel buyViewModel = new BuyViewModel();

            buyViewModel.BuyBooks = new ObservableCollection <BuyEntity>(App.Db.SaleRepository.GetAll());
            DataContext           = buyViewModel;
        }
Beispiel #13
0
        public BuyStockCommand(BuyViewModel buyViewModel, IBuyStockService buyStockService, IAccountStore accountStore)
        {
            _buyViewModel    = buyViewModel;
            _buyStockService = buyStockService;
            _accountStore    = accountStore;

            _buyViewModel.PropertyChanged += BuyViewModel_PropertyChanged;
        }
Beispiel #14
0
 public RootSimpleTraderViewModeltFactory(ISimpleTraderViewModelFactory <HomeViewModel> homeViewModelFactory,
                                          ISimpleTraderViewModelFactory <PortfolioViewModel> portfolioViewModelFactory,
                                          BuyViewModel buyViewModel)
 {
     _homeViewModelFactory      = homeViewModelFactory;
     _portfolioViewModelFactory = portfolioViewModelFactory;
     _buyViewModel = buyViewModel;
 }
Beispiel #15
0
        public BuyPage(Repair repair)
        {
            InitializeComponent();

            //label1.Text = repair.Work.Name;
            //label3.Text = repair.GetPrice.ToString();
            //label2.Text = repair.Options.Count.ToString();
            BindingContext = this.viewModel = new BuyViewModel(repair, this);
        }
Beispiel #16
0
        public async Task <Buy> Process(BuyViewModel model)
        {
            await _buyRepository.Save(model.Buy);

            var payload = MapPayload(model);

            _eventBus.PublishEvent(payload, "buys");

            return(model.Buy);
        }
Beispiel #17
0
        public ActionResult Edit(int id)
        {
            var buy = db.Buys.Include(x => x.BuyProductos)
                      .FirstOrDefault(x => x.BuyId == id);
            var vm = new BuyViewModel();

            vm.Buy       = buy;
            vm.Productos = db.Productoes.OrderBy(x => x.NombreProducto).ToList();
            return(View(vm));
        }
Beispiel #18
0
        public async Task <IActionResult> Buy(int id)
        {
            var model = new BuyViewModel();

            model.listing = _context.BookListings.Where(a => a.ID == id).FirstOrDefault();
            model.book    = _context.Books.Where(a => a.ID == model.listing.BookID).FirstOrDefault();
            model.seller  = await _userManager.FindByIdAsync(model.listing.ApplicationUserID);

            return(View(model));
        }
Beispiel #19
0
        public IHttpActionResult GetBuyforUserId(Guid userid)
        {
            string     str = "SELECT UserId,(select CoinName from tbl_Coin_Master where Id=CoinTypeId) as Coin_Name,DestinationofBitCoins,Amount_In_USD,Amount_In_Coins,Fee,Tax,Total,PaymentTYpe,Insert_Date,Updated_Date FROM tbl_USD_Coin_Buy where userid='" + userid + "'";
            SqlCommand cmd = new SqlCommand(str, con);

            con.Open();
            SqlDataReader       dr = cmd.ExecuteReader();
            List <BuyViewModel> ls = new List <BuyViewModel>();

            while (dr.Read())
            {
                BuyViewModel ob = new BuyViewModel();
                ob.UserId             = dr[0].ToString();
                ob.CoinName           = (string)dr[1];
                ob.DestinationBitcoin = (string)dr[2];
                ob.AmtInUSD           = (decimal)dr[3];
                ob.AmtInCoins         = (decimal)dr[4];
                ob.Fee         = (decimal)dr[5];
                ob.Tax         = (decimal)dr[6];
                ob.Total       = (decimal)dr[7];
                ob.PaymentType = (string)dr[8];
                ob.InsertDate  = (DateTime)dr[9];
                if (dr[10] == DBNull.Value)
                {
                    ob.UpdateDate = null;
                }
                else
                {
                    ob.UpdateDate = (DateTime)dr[10];
                }
                ls.Add(ob);
            }
            dr.Close();
            con.Close();
            //SqlDataAdapter da = new SqlDataAdapter(str, con);
            //DataSet ds = new DataSet();
            //da.Fill(ds);
            //DataTable dt = new DataTable();
            //dt = ds.Tables[0];
            //con.Close();
            //string jsonstring = JsonConvert.SerializeObject(dt);
            //return Ok(jsonstring);
            if (ls.Count == 0)
            {
                return(NotFound());
            }

            return(Ok(ls));
            //}
            //catch (Exception ex)
            //{
            //    return Ok("Records not found");
            //}
        }
Beispiel #20
0
        private PaymentPublishedPayload MapPayload(BuyViewModel model)
        {
            var payload = new  PaymentPublishedPayload
            {
                BuyId  = model.Buy.Id,
                Amount = model.Buy.Amount,
                Card   = model.Card
            };

            return(payload);
        }
        public ActionResult Buy(int?Id)
        {
            BuyViewModel viewModel = new BuyViewModel();

            viewModel.Flight  = flightBusinessLogic.FindFlight(Id);
            viewModel.Tickets = ticketBuisnessLogic.GetTickets(Id);
            if (viewModel.Tickets.Where(e => string.IsNullOrEmpty(e.Status)).Count() == 0)
            {
                return(HttpNotFound());
            }

            return(View(viewModel));
        }
        public ActionResult Buy()
        {
            if (IsLogon())
            {
                BuyViewModel model = new BuyViewModel();
                var          user  = CurrentUserId();
                model.Addresseses = Context.Addresses.Where(x => x.Member_Id == user).ToList();
                model.BasketView  = ((List <BasketViewModel>)Session["Basket"]).ToList();
                return(View(model));
            }

            return(RedirectToAction("Login", "Account"));
        }
Beispiel #23
0
        public ActionResult Buy()
        {
            var reservations    = Context.Reservations.ToList();
            var serviceProducts = Context.ServiceProducts.ToList();

            var viewModel = new BuyViewModel()
            {
                Reservations    = reservations,
                ServiceProducts = serviceProducts
            };

            return(View("SelectItems", viewModel));
        }
 public ActionResult BuyForm(BuyViewModel pass)
 {
     pass.Passenger.Sex = pass.Sex.ToString();
     if (ticketBuisnessLogic.BuyTicket(pass.Passenger, pass.Count, pass.Flight.FlightId, pass.ToClass.ToString()))
     {
         ViewBag.Message = "Покупку здійснено";
         ViewBag.Name    = pass.Passenger.FirstName;
         return(View("PurchaseSuccessful"));
     }
     else
     {
         ViewBag.Message = "Помилка заповнення форми";
         return(View("InfoAndErrors"));
     }
 }
        public BuyUserControl(BookViewModel bookViewModel)
        {
            InitializeComponent();
            BuyViewModel buyViewModel = new BuyViewModel();

            buyViewModel.CurrentBuyBook        = new BuyEntity();
            buyViewModel.CurrentBuyBook.BookId = bookViewModel.CurrentBook.BranchId;
            buyViewModel.CurrentBuyBook.Book   = bookViewModel.CurrentBook;
            buyViewModel.CurrentBuyBook.User   = App.Db.UserRepository.GetUserPresenly();
            buyViewModel.CurrentBuyBook.UserId = buyViewModel.CurrentBuyBook.User.Id;
            buyViewModel.CurrentBuyBook.Date   = DateTime.Now;
            buyViewModel.customerList          = App.Db.CustomerRepository.GetAll();

            DataContext = buyViewModel;
        }
Beispiel #26
0
        public IActionResult Buy(BuyViewModel model)
        {
            var buy = new Bought()
            {
                Name         = model.Name,
                Address      = model.Address,
                DeliveryType = model.DeliveryType,
                PhoneNumber  = model.PhoneNumber
            };

            this.context.Bought.Add(buy);
            this.context.SaveChanges();

            return(this.View());
        }
Beispiel #27
0
        //[Authorize]
        //public ActionResult SelectShippingAddress(int Id)
        //{
        //    var product = db.Products.Single(p => p.ProductId == Id);
        //    string id = User.Identity.GetUserId();
        //    var user = db.AspNetUsers.Single(u => u.Id == id);
        //    var svm = new ShippingViewModel
        //    {
        //        User = user,
        //        Product = product,
        //        Addresses = db.Addresses.Where(u=>u.AspNetUser.Id==id).ToList(),
        //        States = db.States.ToList()

        //    };

        //    return View(svm);
        //}


        public ActionResult EditShippingAddress(int id, int productid)
        {
            var address = db.Addresses.Single(a => a.AddressId == id);
            var product = db.Products.Single(p => p.ProductId == productid);
            var bvm     = new BuyViewModel
            {
                Product      = product,
                address      = address,
                AddressBook  = db.Addresses.ToList(),
                States       = db.States.ToList(),
                PaymentModes = db.Payments.ToList(),
            };

            return(View(bvm));
        }
Beispiel #28
0
        public async Task Buy(string userEmail, BuyViewModel viewModel)
        {
            var user = await _userService.GetUserByEmail(userEmail);

            var product     = _productService.GetById(viewModel.ProductId);
            var transaction = new Transaction
            {
                Company  = product.Company,
                Product  = product,
                DotzCost = product.RewardInDotz,
                Wallet   = user.Wallet
            };

            _transactionService.Buy(transaction);
        }
 public ActionResult Create(BuyViewModel buy)
 {
     if (!ModelState.IsValid)
     {
         ErrorNotification("Kayıt Eklenemedi!");
         return(RedirectToAction("Create"));
     }
     _buyService.Add(new Buy
     {
         //TODO:Alanlar buraya yazılacak
         //Örn:BrandName = brand.BrandName,
     });
     SuccessNotification("Kayıt Eklendi.");
     return(RedirectToAction("BuyIndex"));
 }
Beispiel #30
0
        public CurrenciesPage(BuyViewModel buyViewModel)
        {
            InitializeComponent();

            string selectedColorName = "ListViewSelectedBackgroundColor";

            if (Application.Current.RequestedTheme == OSAppTheme.Dark)
            {
                selectedColorName = "ListViewSelectedBackgroundColorDark";
            }

            Application.Current.Resources.TryGetValue(selectedColorName, out var selectedColor);
            selectedItemBackgroundColor = (Color)selectedColor;

            BindingContext = buyViewModel;
        }
Beispiel #31
0
        public ActionResult SelectItems(BuyViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("SelectItems", viewModel));
            }

            var buyViewModel = new BuyViewModel()
            {
                ReservationId    = viewModel.ReservationId,
                ServiceProductId = viewModel.ServiceProductId,
                Quantity         = viewModel.Quantity
            };

            return(RedirectToAction("CompletePurchase", buyViewModel));
        }
 public ActionResult Buy()
 {
     BuyViewModel vm = new BuyViewModel() { Limit = 99999 };
     return View(vm);
 }