Ejemplo n.º 1
0
        public ActionResult Operation(string income)
        {
            if (item.State)
            {
                user.Money += Convert.ToInt32(income);
            }
            else
            {
                user.Money -= Convert.ToInt32(income);
            }
            foreach (var b in context.Users)
            {
                if (b.Id == user.Id)
                {
                    b.Money = user.Money;
                }
            }

            Hystory hystory = new Hystory();

            hystory.MoneyManagerItemId = item.Id;
            hystory.Name      = item.Name;
            hystory.Operation = item.State ? "+" + income : "-" + income;
            hystory.UserId    = user.Id;
            hystory.Date      = DateTime.Now;

            context.Hystories.Add(hystory);
            context.SaveChanges();

            ForViewBug();

            return(View("Index"));
        }
 public HystoryViewModel()
 {
     _hystory = new Hystory()
     {
         datum = "01.01.1990", aktuellerWert = 500
     };
 }
Ejemplo n.º 3
0
        public ActionResult Operation(string select, string income)
        {
            int id = Convert.ToInt32(select);

            wallet = context.Wallets.FirstOrDefault(wal => wal.Id == id);
            if (item.State)
            {
                user.Money   += Convert.ToInt32(income);
                wallet.Money += Convert.ToInt32(income);
                item.Balance += Convert.ToInt32(income);
            }
            else
            {
                user.Money   -= Convert.ToInt32(income);
                wallet.Money -= Convert.ToInt32(income);
                item.Balance -= Convert.ToInt32(income);
            }
            foreach (var b in context.Users)
            {
                if (b.Id == user.Id)
                {
                    b.Money = user.Money;
                }
            }
            foreach (var b in context.MoneyManagerItems.Where(i => i.UserId == user.Id))
            {
                if (b.Id == item.Id)
                {
                    b.Balance = item.Balance;
                }
            }

            Hystory hystory = new Hystory();

            hystory.MoneyManagerItemId = item.Id;
            hystory.Name       = item.Name;
            hystory.Operation  = item.State ? "+" + income : "-" + income;
            hystory.UserId     = user.Id;
            hystory.Date       = DateTime.Now;
            hystory.WalletName = wallet.Name;

            context.Hystories.Add(hystory);
            context.SaveChanges();

            ForViewBug();

            return(View("Index"));
        }