示例#1
0
        public AboutMeModule(IAboutMeRepository repo) : base("/posts")
        {
            this._repo = repo;
            this.InitPost();
            Get("/", async args =>
            {
                var post = await this._repo.GetFirstPost();
                return(Response.AsJson(post));
            });
            Get("/all", async args =>
            {
                var posts = await this._repo.GetAllPosts();
                return(Response.AsJson(posts));
            });

            Post("/", async args =>
            {
                this.RequiresAuthentication();
                this.RequiresClaims(c => c.Value.Equals("admin"));

                var post = this.Bind <AboutMe>();

                if (String.IsNullOrWhiteSpace(post.Text))
                {
                    return(Response.AsJson(new { Status = "error", Message = "There has to be SOME text" }));
                }

                await this._repo.AddPost(post);
                return(Response.AsJson(new { Status = "success", Message = "Done" }));
            });
        }
示例#2
0
 public AboutMeLogic(IAboutMeRepository aboutMeRepository)
 {
     _aboutMeRepository = aboutMeRepository;
 }
示例#3
0
 public AboutMeController(IAboutMeRepository repository)
 {
     this.repository = repository;
 }
示例#4
0
 public Bootstrapper(string mongodbUrl)
 {
     this._subscriberRepository = new SubscriberRepository(mongodbUrl);
     this._userRepository       = new UserRepository(mongodbUrl);
     this._aboutMeRepository    = new AboutMeRepository(mongodbUrl);
 }