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(); }
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); }
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); }
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()); }
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; } } }
internal static void Delete(int accountID, MataDBEntities db) { db.Token.RemoveRange(db.Token.Where(q => q.AccountID == accountID)); db.SaveChanges(); }