コード例 #1
0
        public static Browser CreateBrowser(IBarCodes createBarcodes)
        {
            var browser = new Browser(with =>
            {
                with.Module <AttachBarCodeModule>();
                with.Dependency(createBarcodes);
            });

            return(browser);
        }
コード例 #2
0
        public CommentsModule(IBarCodes barCodes, IComments comments,
                              IUsers users, IEventLog eventLog, IGravatarService gravatarService) : base("/Comment")
        {
            this.RequiresAuthentication();

            this.barCodes        = barCodes;
            this.comments        = comments;
            this.users           = users;
            this.eventLog        = eventLog;
            this.gravatarService = gravatarService;

            Get["/{id}"] = x =>
            {
                if (!this.barCodes.Exists(x.id))
                {
                    return(Response.AsJson(Enumerable.Empty <Comment>()));
                }

                IEnumerable <Comment> commentsForBarCode = this.comments.GetCommentsForBarCode(x.id);
                Comment[]             ret =
                    this.gravatarService.AddAvatarToComments(commentsForBarCode).ToArray();
                return(Response.AsJson(ret));
            };

            Post["/{id}"] = x =>
            {
                if (!this.barCodes.Exists(x.id))
                {
                    return(Response.AsJson(Enumerable.Empty <Comment>()));
                }

                Comment comment = this.Bind <Comment>();
                comment.Author = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);

                this.comments.Add(comment);
                Comment[] commentsForBarCode = this.comments.GetCommentsForBarCode(x.id).ToArray();
                this.Log(x.id, comment.Author, "COMMENT", comment.Text);
                return(Response.AsJson(commentsForBarCode));
            };
        }
コード例 #3
0
        public CommentsModule(IBarCodes barCodes, IComments comments, 
            IUsers users, IEventLog eventLog, IGravatarService gravatarService)
            : base("/Comment")
        {
            this.RequiresAuthentication();

            this.barCodes = barCodes;
            this.comments = comments;
            this.users = users;
            this.eventLog = eventLog;
            this.gravatarService = gravatarService;

            Get["/{id}"] = x =>
                               {
                                   if (!this.barCodes.Exists(x.id))
                                       return Response.AsJson(Enumerable.Empty<Comment>());

                                   IEnumerable<Comment> commentsForBarCode = this.comments.GetCommentsForBarCode(x.id);
                                   Comment[] ret =
                                       this.gravatarService.AddAvatarToComments(commentsForBarCode).ToArray();
                                   return Response.AsJson(ret);
                               };

            Post["/{id}"] = x =>
                                {
                                    if (!this.barCodes.Exists(x.id))
                                        return Response.AsJson(Enumerable.Empty<Comment>());

                                    Comment comment = this.Bind<Comment>();
                                    comment.Author = this.users.GetIdByUsername(this.Context.CurrentUser.UserName);

                                    this.comments.Add(comment);
                                    Comment[] commentsForBarCode = this.comments.GetCommentsForBarCode(x.id).ToArray();
                                    this.Log(x.id, comment.Author, "COMMENT", comment.Text);
                                    return Response.AsJson(commentsForBarCode);
                                };
        }
コード例 #4
0
 public CreateBarCodeUseCase(IBarCodes barCodes)
 {
     _barCodes = barCodes;
 }
コード例 #5
0
 public BarCodeController(IBarCodes barCodes, IApiSearchService apiSearchService)
 {
     this.barCodes         = barCodes;
     this.apiSearchService = apiSearchService;
 }
コード例 #6
0
 public ExtractQrCodeUseCase(IBarCodes barCodes)
 {
     _barCodes = barCodes;
 }
コード例 #7
0
 public BarCodeController(IBarCodes barCodes, IApiSearchService apiSearchService)
 {
     this.barCodes = barCodes;
     this.apiSearchService = apiSearchService;
 }