예제 #1
0
        public AccountDTO Add(AccountDTO x)
        {
            var obj = x.toModel();

            try
            {
                db.Accounts.Add(obj);
                db.SaveChanges();
            }
            catch
            {
                return(null);
            }
            return(new AccountDTO(obj));
        }
예제 #2
0
        public AccountDTO Update(AccountDTO x)
        {
            var a = db.Accounts.Find(x.ID);

            if (a != null)
            {
                try
                {
                    a = x.toModel();
                    db.SaveChanges();
                }
                catch
                {
                    return(null);
                }
                return(new AccountDTO(a));
            }
            return(null);
        }