Beispiel #1
0
 private void Window_Drop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
     {
         string dPath = ((Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(0).ToString();
         BAViewModel.SearchPictures(dPath);
     }
 }
        public IActionResult Account(int userId)
        {
            int?loggedUserId = HttpContext.Session.GetInt32("User");
            var loggedUser   = db.Users.FirstOrDefault(u => u.UserId == loggedUserId);

            if (db.Users.Any(u => u.UserId == loggedUserId))
            {
                if (loggedUserId != userId)
                {
                    return(RedirectToAction("Account", new { userId = loggedUserId }));
                }

                BAViewModel trans = new BAViewModel();
                trans.CurrentUser        = db.Users.Include(u => u.Transactions).FirstOrDefault(u => u.UserId == loggedUserId);
                trans.AllUserTransaction = db.Users.Include(u => u.Transactions).FirstOrDefault(u => u.UserId == loggedUserId).Transactions.OrderByDescending(t => t.CreatedAt).ToList();
                return(View("Account", trans));
            }
            return(RedirectToAction("LogIn"));
        }
        public IActionResult Maketrans(BAViewModel change)
        {
            int? loggedUserId = HttpContext.Session.GetInt32("User");
            User loggedUser   = db.Users.FirstOrDefault(u => u.UserId == loggedUserId);

            if (ModelState.IsValid)
            {
                if (change.Transaction.Amount > 0 && loggedUser.Balance < change.Transaction.Amount)
                {
                    ModelState.AddModelError("Amount", "Insuffisiant funds");
                }

                change.Transaction.UserId = (int)loggedUserId;
                loggedUser.Balance       += change.Transaction.Amount;
                db.Transactions.Update(change.Transaction);
                db.Users.Update(loggedUser);
                db.SaveChanges();
                return(RedirectToAction("Account", new { userId = loggedUserId }));
            }
            return(View("Account", change));
        }
Beispiel #4
0
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     this.Loaded -= MainWindow_Loaded;
     BAViewModel.IniContainer(this.BrushCoverage, this.FindResource(inkCanvasStyleKey));
 }