Exemplo n.º 1
0
        public PartFailsModule(
            IFacadeService <PartFail, int, PartFailResource, PartFailResource> partFailService,
            IFacadeService <PartFailFaultCode, string, PartFailFaultCodeResource, PartFailFaultCodeResource> faultCodeService,
            IFacadeService <PartFailErrorType, string, PartFailErrorTypeResource, PartFailErrorTypeResource> errorTypeService,
            IPartsReportFacadeService partsReportFacadeService,
            IPartFailSupplierService partFailSupplierService)
        {
            this.partFailService          = partFailService;
            this.errorTypeService         = errorTypeService;
            this.partsReportFacadeService = partsReportFacadeService;
            this.partFailSupplierService  = partFailSupplierService;
            this.faultCodeService         = faultCodeService;

            this.Post("/production/quality/part-fails", _ => this.Add());
            this.Get("/production/quality/part-fails", _ => this.Search());
            this.Get("/production/quality/part-fails/create", _ => this.GetApp());
            this.Get("/production/quality/part-fails/{id}", parameters => this.GetById(parameters.id));

            this.Put("/production/quality/part-fails/{id}", parameters => this.Update(parameters.id));

            this.Get("/production/quality/part-fail-error-types", _ => this.GetErrorTypes());
            this.Get("/production/quality/part-fail-error-types/{type*}", parameters => this.GetErrorType(parameters.type));
            this.Put("/production/quality/part-fail-error-types/{type*}", parameters => this.UpdateErrorType(parameters.type));
            this.Post("/production/quality/part-fail-error-types", parameters => this.AddErrorType());

            this.Get("/production/quality/part-fail-fault-codes", _ => this.GetFaultCodes());
            this.Get("/production/quality/part-fail-fault-codes/{code*}", parameters => this.GetFaultCode(parameters.code));
            this.Put("/production/quality/part-fail-fault-codes/{code*}", parameters => this.UpdateFaultCode(parameters.code));
            this.Post("/production/quality/part-fail-fault-codes", parameters => this.AddFaultCode());

            this.Get("/production/quality/part-fails/detail-report/report", _ => this.GetPartFailDetailsReport());
            this.Get("/production/quality/part-fails/detail-report", _ => this.GetPartFailsDetailReportOptions());

            this.Get("/production/quality/part-fails/suppliers", _ => this.GetPartFailSuppliers());
        }
Exemplo n.º 2
0
        public void EstablishContext()
        {
            this.FacadeService = Substitute
                                 .For <IFacadeService <PartFail, int, PartFailResource, PartFailResource> >();
            this.ErrorTypeService =
                Substitute
                .For <IFacadeService <PartFailErrorType, string, PartFailErrorTypeResource, PartFailErrorTypeResource> >();
            this.FaultCodeService =
                Substitute
                .For <IFacadeService <PartFailFaultCode, string, PartFailFaultCodeResource, PartFailFaultCodeResource> >();
            this.PartsReportFacadeService = Substitute.For <IPartsReportFacadeService>();
            this.PartFailSupplierService  = Substitute.For <IPartFailSupplierService>();

            var bootstrapper = new ConfigurableBootstrapper(
                with =>
            {
                with.Dependency(this.FacadeService);
                with.Dependency(this.FaultCodeService);
                with.Dependency(this.ErrorTypeService);
                with.Dependency(this.PartsReportFacadeService);
                with.Dependency(this.PartFailSupplierService);
                with.Dependency <IResourceBuilder <PartFail> >(new PartFailResourceBuilder());
                with.Dependency <IResourceBuilder <IEnumerable <PartFail> > >(new PartFailsResourceBuilder());
                with.Dependency <IResourceBuilder <PartFailErrorType> >(new PartFailErrorTypeResourceBuilder());
                with.Dependency <IResourceBuilder <IEnumerable <PartFailErrorType> > >(new PartFailErrorTypesResourceBuilder());
                with.Dependency <IResourceBuilder <PartFailFaultCode> >(new PartFailFaultCodeResourceBuilder());
                with.Dependency <IResourceBuilder <IEnumerable <PartFailFaultCode> > >(new PartFailFaultCodesResourceBuilder());
                with.Dependency <IResourceBuilder <ResultsModel> >(new ResultsModelResourceBuilder());
                with.Dependency <IResourceBuilder <IEnumerable <ResultsModel> > >(
                    new ResultsModelsResourceBuilder());
                with.Dependency <IResourceBuilder <PartFailSupplierView> >(new PartFailSupplierResourceBuilder());
                with.Dependency <IResourceBuilder <IEnumerable <PartFailSupplierView> > >(
                    new PartFailSuppliersResourceBuilder());
                with.Module <PartFailsModule>();
                with.ResponseProcessor <PartFailResponseProcessor>();
                with.ResponseProcessor <PartFailsResponseProcessor>();
                with.ResponseProcessor <PartFailErrorTypeResponseProcessor>();
                with.ResponseProcessor <PartFailErrorTypesResponseProcessor>();
                with.ResponseProcessor <PartFailFaultCodeResponseProcessor>();
                with.ResponseProcessor <PartFailFaultCodesResponseProcessor>();
                with.ResponseProcessor <ResultsModelsJsonResponseProcessor>();
                with.ResponseProcessor <ResultsModelJsonResponseProcessor>();
                with.ResponseProcessor <PartFailSupplierResponseProcessor>();
                with.ResponseProcessor <PartFailSuppliersResponseProcessor>();
                with.RequestStartup(
                    (container, pipelines, context) =>
                {
                    var claims = new List <Claim>
                    {
                        new Claim(ClaimTypes.Role, "employee"),
                        new Claim(ClaimTypes.NameIdentifier, "test-user")
                    };
                    var user = new ClaimsIdentity(claims, "jwt");

                    context.CurrentUser = new ClaimsPrincipal(user);
                });
            });

            this.Browser = new Browser(bootstrapper);
        }