public async Task<List<User>> GetAll() { using (testdbContext db = new testdbContext()) { var ls = (from u in db.User select u).ToList(); return ls; } }
public async Task <UserAccount> GetLogedInUserProfile(string userName, string password) { using (var context = new testdbContext()) { return(await context.UserAccount .Include(u => u.Role) .FirstOrDefaultAsync(u => u.UserName == userName && u.Password == password && u.IsActive)); } }
public async Task <bool> AddLogin(AppaAccessLog appaAccessLog) { using (var context = new testdbContext()) { await context.AppaAccessLog.AddAsync(appaAccessLog); return(await context.SaveChangesAsync() > 0); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); db = new testdbContext(); db.Staffs.Load(); staffBindingSource.DataSource = db.Staffs.Local.ToBindingList(); }
public async Task <UserAccount> GetUserProfile(Guid userId) { using (var context = new testdbContext()) { return(await context.UserAccount .Include(u => u.Role) .Include(u => u.Company) .FirstOrDefaultAsync(u => u.Id == userId && u.IsActive)); } }
async Task IUserService.Delete(int UserId) { using (testdbContext db = new testdbContext()) { //Creo el objeto -> User obj = db.User.Find(UserId); //Insert -> db.User.Remove(obj); await db.SaveChangesAsync(); } }
public async Task <bool> UpdateLogin(AppaAccessLog appaAccessLog) { using (var context = new testdbContext()) { var login = await context.AppaAccessLog .FirstOrDefaultAsync(l => l.UserId == appaAccessLog.UserId && l.IsActive); if (login != null) { login.Token = appaAccessLog.Token; login.RefreshToken = appaAccessLog.RefreshToken; login.UpdatedDateTime = DateTimeOffset.UtcNow; } return(await context.SaveChangesAsync() > 0); } }
async Task<int> IUserService.Insert(UserRequest model) { using (testdbContext db = new testdbContext()) { //Creo el objeto -> User obj = new User(); obj.UserName = model.UserName; obj.Name = model.Name; obj.Email = model.Email; obj.Phone = model.Phone; //Insert -> await db.AddAsync(obj); await db.SaveChangesAsync(); return obj.UserId; } }
async Task IUserService.Upload(UserRequestEdit model) { using (testdbContext db = new testdbContext()) { //Creo el objeto -> User obj = db.User.Find(model.UserId); if (obj != null) { obj.UserName = model.UserName; obj.Name = model.Name; obj.Email = model.Email; obj.Phone = model.Phone; //Actualizo -> db.Entry(obj).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await db.SaveChangesAsync(); } else throw new Exception("El usuerio no existe"); } }
public ProductsController(testdbContext context) { _context = context; }
public PeopleController(testdbContext context) { _context = context; }
public Processing(testdbContext testdbContext) { _testdbContext = testdbContext; }