Esempio n. 1
0
        public String insertWallet(String name, int money)
        {
            using (var context = new QLTCDbEntities())
            {
                var k = (from a in context.Wallets
                         select a.ID).ToList();

                int id = k.Count();
                id++;
                var checkName = (from a in context.Wallets
                                 where a.Name.Equals(name)
                                 select a).ToList();
                if (checkName.Count() > 0)
                {
                    return("1");
                }
                else
                {
                    Wallet wallet = new Wallet()
                    {
                        ID         = id,
                        Name       = name,
                        FirstMoney = money,
                        Money      = money
                    };
                    context.Wallets.Add(wallet);
                    context.Entry(wallet).State = EntityState.Added;
                    context.SaveChanges();
                    return("0");
                }
            }
        }
 public void AddAction(String name)
 {
     using (var context = new QLTCDbEntities())
     {
         var i = (from a in context.ActionNames
                  select a).ToList();
         int id = i.Count();
         id++;
         ActionName action = new ActionName()
         {
             ID          = id,
             ActionName1 = name
         };
         context.ActionNames.Add(action);
         context.Entry(action).State = EntityState.Added;
         context.SaveChanges();
     }
 }
        public String AddNewHistory(String action,
                                    String wallet,
                                    int money,
                                    DateTime dateUse)
        {
            using (var context = new QLTCDbEntities())

                if (checkValidate(money).Equals("Success"))
                {
                    int i_action = (from a in context.ActionNames
                                    where a.ActionName1.Equals(action)
                                    select a.ID).FirstOrDefault();
                    int i_wallet = (from a in context.Wallets
                                    where a.Name.Equals(wallet)
                                    select a.ID).FirstOrDefault();
                    var i = (from a in context.MemoryActions
                             select a.ID).ToList();
                    int id = i.Count();

                    MemoryAction m = new MemoryAction()
                    {
                        ID        = id,
                        ID_action = i_action,
                        ID_wallet = i_wallet,
                        Money     = money,
                        DateUse   = dateUse
                    };

                    context.MemoryActions.Add(m);
                    context.Entry(m).State = EntityState.Added;
                    context.SaveChanges();
                    return("Success");
                }
                else
                {
                    return(checkValidate(money));
                }
        }