Exemple #1
0
        public dynamic Add()
        {
            if (this.id > 0)
            {
                return(false);
            }

            WpfEntities db = new WpfEntities();

            try
            {
                db.Customers.Add(this);
                db.SaveChanges();

                return(this.id);
            }
            catch (Exception Exception)
            {
                //JDR: Exception can be logged here
                Console.WriteLine("***EROR_CATCH*** - An error occurred: '{0}'", Exception);

                return(false);
            }
            finally
            {
                db.Dispose();
            }
        }
Exemple #2
0
        public bool Save()
        {
            WpfEntities db = new WpfEntities();

            try
            {
                db.Entry(this).State = EntityState.Modified;

                db.SaveChanges();

                return(true);
            }
            catch (Exception Exception)
            {
                //JDR: Exception can be logged here
                Console.WriteLine("***EROR_CATCH*** - An error occurred: '{0}'", Exception);

                return(false);
            }
            finally
            {
                db.Dispose();
            }
        }