public UserData GetFromAccount(AccountData account)
        {
            if (account == null)
            {
                throw new ArgumentNullException("account");
            }
            UserQuery query = new UserQuery();

            query.Filter = new UserQuery.IdFilter(account.Id);

            var result = query.Execute().ToList();

            if (result.Count > 0)
            {
                UserModel user = result[0];
                return(new UserData()
                {
                    Id = user.Identity,
                    ImageFileLocation = $@"{Configuration.Instance.UserImageDirectoryPath}\{user.ImageFilename}",
                    Firstname = user.Firstname,
                    Middlename = user.Middlename,
                    Lastname = user.Lastname,
                    Gender = user.Gender,
                    BirthDate = user.BirthDate,
                    ContactNumber = user.ContactNumber,
                    Email = user.Email,
                    Address = user.Address
                });
            }

            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public void foo()
        {
            UserQuery q = new UserQuery();

            q.Filter = new UserQuery.NameFilter("The Name")
                       .And(new UserQuery.GenderFilter(Common.Type.Gender.Male)
                            .Or(new UserQuery.IdFilter(2))
                            .CreateBrackets());

            q.Execute();
        }
Beispiel #3
0
        public UserTests()
        {
            Helpers.Loader.ReloadDb();
            db = new CommandRunner("dvds");
            var userQuery = new UserQuery(db)
            {
                Email = "*****@*****.**"
            };

            user = userQuery.Execute();
            //user = db.ExecuteSingle<User>("select * from users;");
        }
Beispiel #4
0
 public IHttpActionResult Query(UserQuery model)
 {
     if (!model.validate())
     {
         return(BadRequest("Only select querys are granted !"));
     }
     try
     {
         return(Ok(model.Execute()));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
        public IEnumerable <UserData> GetUsers()
        {
            UserQuery query = new UserQuery();

            List <UserModel> userModels = query.Execute().ToList();

            return(from user in userModels
                   select new UserData()
            {
                Id = user.Identity,
                ImageFileLocation = $@"{Configuration.Instance.UserImageDirectoryPath}\{user.ImageFilename}",
                Firstname = user.Firstname,
                Middlename = user.Middlename,
                Lastname = user.Lastname,
                Gender = user.Gender,
                BirthDate = user.BirthDate,
                ContactNumber = user.ContactNumber,
                Email = user.Email,
                Address = user.Address
            });
        }