Esempio n. 1
0
        public async Task<List<User>> GetAll()
        {
            using (testdbContext db = new testdbContext())
            {
                var ls = (from u in db.User select u).ToList();

                return ls;
            }
        }
Esempio n. 2
0
 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));
     }
 }
Esempio n. 3
0
        public async Task <bool> AddLogin(AppaAccessLog appaAccessLog)
        {
            using (var context = new testdbContext())
            {
                await context.AppaAccessLog.AddAsync(appaAccessLog);

                return(await context.SaveChangesAsync() > 0);
            }
        }
Esempio n. 4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            db = new testdbContext();

            db.Staffs.Load();

            staffBindingSource.DataSource = db.Staffs.Local.ToBindingList();
        }
Esempio n. 5
0
 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));
     }
 }
Esempio n. 6
0
        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();
            }
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
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;
            }
        }
Esempio n. 9
0
        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");
            }
        }
Esempio n. 10
0
 public ProductsController(testdbContext context)
 {
     _context = context;
 }
Esempio n. 11
0
 public PeopleController(testdbContext context)
 {
     _context = context;
 }
Esempio n. 12
0
 public Processing(testdbContext testdbContext)
 {
     _testdbContext = testdbContext;
 }