Beispiel #1
0
        public static IEnumerable<Report> GetByUser(IApiUserSource api, User user)
        {
            using (MongoConnection db = FooRuntime.GetDatabase())
            {
                QueryDocument query = new QueryDocument();
                query.AddApiConstraint(api);
                query.Add("ownerUserId", user._id);

                return db.GetCollection<Report>().Find(query);
            }
        }
Beispiel #2
0
        public static User CreateUser(IApiUserSource api, string username, string email, string password)
        {
            User user = new User();
            user.SetApi(api);
            user.Username = username;
            user.Email = email;
            user.SetPassword(password);

            // dump...
            using (MongoConnection db = FooRuntime.GetDatabase())
                db.GetCollection<User>().Insert(user);

            // return...
            return user;
        }
Beispiel #3
0
        public static Token CreateToken(IApiUserSource api, User user)
        {
            Token item = new Token();
            item.SetApi(api);
            item.TheToken = Guid.NewGuid();
            item.UserId = user._id;
            item.UpdateExpiration(false);

            // save...
            using (MongoConnection db = FooRuntime.GetDatabase())
                db.GetCollection<Token>().Insert(item);

            // return...
            return item;
        }
Beispiel #4
0
        public static Report CreateReport(IApiUserSource api, User owner, string title, string description, decimal latitude, decimal longitude)
        {
            Report report = new Report();
            report.SetApi(api);
            report.OwnerUserId = owner._id;
            report.Title = title;
            report.Description = description;
            report.Latitude = latitude;
            report.Longitude = longitude;

            // dump...
            using (MongoConnection db = FooRuntime.GetDatabase())
                db.GetCollection<Report>().Insert(report);

            // return...
            return report;
        }
Beispiel #5
0
 internal Report CreateReport(User user)
 {
     return Report.CreateReport(this, user, this.TheTest.GetRandomId("title"), this.TheTest.GetRandomId("description"), 0M, 0M);
 }
Beispiel #6
0
        protected void ApplyLogonToken(JsonData input, User user)
        {
            Token token = Token.CreateToken(this, user);
            if (token == null)
                throw new InvalidOperationException("'token' is null.");

            input["logonToken"] = token.TheToken;
        }
Beispiel #7
0
        protected JsonData CreateJsonData(User user)
        {
            JsonData input = new JsonData();
            this.ApplyApiKey(input);
            if (user != null)
                this.ApplyLogonToken(input, user);

            return input;
        }