Ejemplo n.º 1
0
        public void SaveEvent(String title, String location, DateTime date, String category, String occurrence, String user)
        {
            myFinanceDbFileEntities db = new myFinanceDbFileEntities();
            Event newEvent             = new Event();

            var query   = from id in db.Users select id;
            var userRow = query.ToList();

            newEvent.title    = title;
            newEvent.location = location;
            newEvent.date     = date;
            if (category == "Task")
            {
                newEvent.category = 1;
            }
            else
            {
                newEvent.category = 2;
            }
            newEvent.occurrence = occurrence;
            newEvent.UserId     = userRow[0].Id;

            db.Events.AddObject(newEvent);
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
                throw new Exception();
            }
        }
Ejemplo n.º 2
0
        public void SaveTransaction(List <Transaction> transactionList)
        {
            myFinanceDbFileEntities db = new myFinanceDbFileEntities();

            foreach (Transaction tx in transactionList)
            {
                var userQuery = from id in db.Users select id;
                var userRow   = userQuery.ToList();

                //var contactQuery = (from c in db.Contacts where c.Id == tx.ContactId select c).FirstOrDefault<Contact>();

                Transaction newTransaction = new Transaction();
                newTransaction.date        = tx.date;
                newTransaction.amount      = tx.amount;
                newTransaction.type        = tx.type;
                newTransaction.occurrence  = tx.occurrence;
                newTransaction.description = tx.description;
                newTransaction.UserId      = userRow[0].Id;
                db.Transactions.AddObject(newTransaction);
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw new Exception();
            }
        }
Ejemplo n.º 3
0
        private static void insertIntoDatabase(Contact contact)
        {
            myFinanceDbFileEntities db = new myFinanceDbFileEntities();

            db.Contacts.AddObject(contact);
            try
            {
                db.SaveChanges();
                Thread.Sleep(500);
            }
            catch (Exception)
            {
                throw new Exception();
            }
        }