public void RemoveWith(int id) { using (var dbContext = new WebSiteDbContext()) { dbContext.Users.Remove(dbContext.Users.Find(id)); dbContext.SaveChanges(); } }
public int Add(User user) { using (var dbContext = new WebSiteDbContext()) { user.Role = Role.Member; dbContext.Users.Add(user); dbContext.SaveChanges(); return(user.Id); } }
public User GetUserBy(string userName) { using (var dbContext = new WebSiteDbContext()) { var user = dbContext.Users.FirstOrDefault(u => u.UserName == userName); if (user != null) { user.IsValid = true; } return(user); } }