示例#1
0
        public static void Update(int id, AccountDTO accountDTO, MataDBEntities db)
        {
            var account = db.Account.Single(q => q.ID == id);

            account.FullName = accountDTO.FullName;
            account.Email    = accountDTO.Email;
            account.Password = accountDTO.Password;
            account.RoleName = accountDTO.RoleName;

            db.SaveChanges();
        }
示例#2
0
        public static int Create(AccountDTO accountDTO, MataDBEntities db)
        {
            var mapper = new AccountMapper();

            var account = mapper.MapToEntity(accountDTO);

            db.Account.Add(account);
            db.SaveChanges();

            return(account.ID);
        }
示例#3
0
        public static int Create(BackLogDTO backLogDTO, MataDBEntities db)
        {
            var mapper = new BackLogMapper();

            var backLog = mapper.MapToEntity(backLogDTO);

            db.BackLog.Add(backLog);

            db.SaveChanges();

            return(backLog.ID);
        }
示例#4
0
        public static string Create(int accountID, MataDBEntities db)
        {
            var token = new Token()
            {
                AccountID   = accountID,
                StartTime   = DateTime.UtcNow,
                EndTime     = DateTime.UtcNow.AddDays(1),
                TokenString = Guid.NewGuid()
            };

            db.Token.Add(token);
            db.SaveChanges();

            return(token.TokenString.ToString());
        }
示例#5
0
        public static void Delete(int id, MataDBEntities db)
        {
            using (var ts = db.Database.BeginTransaction())
            {
                try
                {
                    var account = db.Account.Single(q => q.ID == id);

                    TokenBL.Delete(account.ID, db);

                    db.Account.Remove(account);
                    db.SaveChanges();

                    ts.Commit();
                }
                catch (Exception)
                {
                    ts.Rollback();
                    throw;
                }
            }
        }
示例#6
0
 internal static void Delete(int accountID, MataDBEntities db)
 {
     db.Token.RemoveRange(db.Token.Where(q => q.AccountID == accountID));
     db.SaveChanges();
 }