Beispiel #1
0
        public async Task <ActionResult <BidDTO> > GetBid(string bidId, [FromQuery] string role)
        {
            string userId = null;

            if (User.Identity.IsAuthenticated)
            {
                userId = GetRequestUserId();
            }
            else if (!role?.Equals("anonymous", System.StringComparison.OrdinalIgnoreCase) ?? false)
            {
                return(this.StatusCode(StatusCodes.Status403Forbidden));
            }
            var      scope             = this.scopeFactory.CreateScope();
            Response updateBidResponse = await BidsUpdateJobs.TryUpdateBidPhaseAndNotify(scope, this.mailService, bidId);

            if (!updateBidResponse.IsOperationSucceeded)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound, updateBidResponse.SuccessOrFailureMessage));
            }

            Response <BidDTO> response = await this.bidsManager.GetBid(bidId, userId, role).ConfigureAwait(false);

            if (response.IsOperationSucceeded)
            {
                response.DTOObject.Id += this.mailPassword + "tzachi";
                return(response.DTOObject);
            }
            // at the moment - we should change the boolean to enum such that we could differ between bad user input ( 400 ) to not found (404)  to unxepected failures ( 500)
            return(this.StatusCode(StatusCodes.Status404NotFound, response.SuccessOrFailureMessage));
        }
Beispiel #2
0
 public DebugController(IServiceScopeFactory scopeFactory, IBidsManager bidsManager, IOptions <MailSettings> mailSettings, IOptions <MailSecrets> mailSecrets, BidsUpdateJobs bidsUpdateJobs)
 {
     this.bidsManager  = bidsManager;
     this.ScopeFactory = scopeFactory;
     MailSettings      = mailSettings.Value;
     MailSecrets       = mailSecrets.Value;
 }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IMapper mapper, BidsUpdateJobs bids)
        {
            RecurringJob.AddOrUpdate("UpdateBidsDaily", () => bids.UpdateBidsPhaseDaily(), Cron.Hourly, TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time"));

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            mapper.ConfigurationProvider.AssertConfigurationIsValid();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseCors();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseMiddleware <CorrelationIdMiddleware>();

            app.UseHangfireDashboard();
            app.UseHangfireServer();
        }