예제 #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));
        }
예제 #2
0
        public async Task <Response> UpdateBidJob(string bidId)
        {
            IMailService mail = new MailService(MailSettings, MailSecrets);

            using (var scope = ScopeFactory.CreateScope())
            {
                return(await BidsUpdateJobs.TryUpdateBidPhaseAndNotify(scope, mail, bidId).ConfigureAwait(false));
            }
        }