public ChallengeBid Price(ChallengeBid value)
        {
            Customer cust = CustRepo.GetWithID(((DareyaIdentity)HttpContext.Current.User.Identity).CustomerID);

            IBillingProcessor processor = BillingSystem.BillingProcessorFactory.
                GetBillingProcessor((BillingSystem.BillingProcessorFactory.SupportedBillingProcessor)cust.BillingType);

            if (processor == null)
            {
                // the customer doesn't have a valid billing provider. don't accept the bid.
                throw new HttpResponseException(System.Net.HttpStatusCode.PaymentRequired);
            }

            decimal approximateFees = Billing.GetFeesForBounty(processor, value.Amount);

            return new ChallengeBid { ComputedFees = approximateFees, Amount = value.Amount };
        }
 public void Update(ChallengeBid bid)
 {
     throw new NotImplementedException();
 }
        public void Bid(ChallengeBid value)
        {
            Challenge c = ChalRepo.Get(value.ChallengeID);
            Customer cust=CustRepo.GetWithID(((DareyaIdentity)HttpContext.Current.User.Identity).CustomerID);

            if (c == null)
                throw new HttpResponseException(System.Net.HttpStatusCode.NotFound);

            if (c.Privacy == (int)Challenge.ChallengePrivacy.FriendsOnly)
            {
                if (Security.DetermineAudience(c) < Security.Audience.Friends)
                    throw new HttpResponseException(System.Net.HttpStatusCode.Forbidden);
            }

            if (BidRepo.CustomerDidBidOnChallenge(cust.ID, c.ID) != null)
                throw new HttpResponseException(System.Net.HttpStatusCode.Conflict);

            IBillingProcessor processor = BillingSystem.BillingProcessorFactory.
                GetBillingProcessor((BillingSystem.BillingProcessorFactory.SupportedBillingProcessor)cust.BillingType);

            if (processor == null)
            {
                // the customer doesn't have a valid billing provider. don't accept the bid.
                throw new HttpResponseException(System.Net.HttpStatusCode.PaymentRequired);
            }

            decimal approximateFees = Billing.GetFeesForBounty(processor, value.Amount);

            ChalRepo.AddBidToChallenge(c, ((DareyaIdentity)HttpContext.Current.User.Identity).CustomerID, value.Amount, approximateFees);

            CustomerNotifier.NotifyChallengeBacked(((DareyaIdentity)HttpContext.Current.User.Identity).CustomerID, c.CustomerID, c.ID);

            Activity activity = new Activity(c.ID, DateTime.UtcNow) { Type = (int)ActivityType.ActivityBackDare, CustomerID = ((DareyaIdentity)HttpContext.Current.User.Identity).CustomerID };
            RepoFactory.GetActivityRepo().Add(activity);

            // auto-accept the dare if the target price is met.
            if (c.TargetPrice > 0 && (c.CurrentBid + (value.Amount - approximateFees) > c.TargetPrice))
                this.Take(c.ID);
        }
 public void UpdateStatusForBidsOnChallenge(long ChallengeID, ChallengeBid.BidStatusCodes NewStatus)
 {
     using (SqlConnection db = new SqlConnection(connStr))
     {
         db.Open();
         db.Execute("UpdateStatusForBidsOnChallenge", new { ChallengeID = ChallengeID, NewStatus = (int)NewStatus }, commandType: CommandType.StoredProcedure);
     }
 }