コード例 #1
0
        public static List <BLL.ViewModels.Users> allUsers()
        {
            List <BLL.ViewModels.Users> toReturn = new List <ViewModels.Users>();

            try
            {
                using (var db = new DLL.Model.Context())
                {
                    var UsersList = db.Users.Where(m => m.active).ToList();
                    int count     = UsersList.Count();
                    for (int i = 0; i < count; i++)
                    {
                        toReturn.Add(new BLL.ViewModels.Users()
                        {
                            accessgroup_name = UsersList[i].accessGroup != null?UsersList[i].accessGroup.name:null,
                            compnay_name     = UsersList[i].company != null?(UsersList[i].company.CompanyName):null,
                            userId           = UsersList[i].UsersId,
                            name             = UsersList[i].name
                        }
                                     );
                    }
                }
            }
            catch (Exception ex)
            {
                return(toReturn);
            }

            return(toReturn);
        }
コード例 #2
0
 public static int editVisitor(BLL.ViewModels.Users user)
 {
     try
     {
         using (var db = new DLL.Model.Context())
         {
             var User = db.Users.Find(user.userId);
             User.accessGroup = db.AccessGroup.Find(user.acessgroup_id);
             User.company     = db.Company.Find(int.Parse(user.company_id));
             User.name        = user.name;
             DLL.Commons.Passwords.setPassword(User, user.password);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return(0);
     }
     return(1);
 }