コード例 #1
0
ファイル: BidRepoDapper.cs プロジェクト: mchambers/Daremeto
 public void Update(ChallengeBid bid)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
ファイル: BidRepoDapper.cs プロジェクト: mchambers/Daremeto
 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);
     }
 }
コード例 #3
0
 public void Add(ChallengeBid bid)
 {
     Database.Bid dbBid = BidToDbBid(bid);
     db.Bid.AddObject(dbBid);
     db.SaveChanges();
 }
コード例 #4
0
        public void Update(ChallengeBid bid)
        {
            db.Bid.Attach(BidToDbBid(bid));

            /*
            Database.Bid dbBid=db.Bid.SingleOrDefault<Database.Bid>(b => b.ID == bid.ID);

            dbBid.Amount = bid.Amount;
            dbBid.ChallengeID = bid.ChallengeID;
            dbBid.CustomerID = bid.CustomerID;
            dbBid.Status = bid.Status;
            */

            db.SaveChanges();
        }
コード例 #5
0
        private ChallengeBid DbBidToBid(Database.Bid d)
        {
            ChallengeBid b = new ChallengeBid();

            b.Amount = d.Amount;
            b.ChallengeID = (long)d.ChallengeID;
            b.CustomerID = d.CustomerID;
            b.ID = d.ID;

            if (d.ComputedFees != null)
                b.ComputedFees = (decimal)d.ComputedFees;
            else
                b.ComputedFees = 0m;

            return b;
        }
コード例 #6
0
        private Database.Bid BidToDbBid(ChallengeBid b)
        {
            Database.Bid d = new Database.Bid();

            if (b.ID > 0)
                d.ID = b.ID;
            d.CustomerID = b.CustomerID;
            d.Amount = b.Amount;
            d.ChallengeID = b.ChallengeID;
            d.ComputedFees = b.ComputedFees;
            return d;
        }
コード例 #7
0
 public void UpdateStatusForBidsOnChallenge(long ChallengeID, string UniqueID, ChallengeBid.BidStatusCodes NewStatus)
 {
     throw new NotImplementedException();
 }
コード例 #8
0
 public void Add(ChallengeBid b)
 {
     context.AddObject(TableName, new ChallengeBidDb(b));
     context.SaveChangesWithRetries();
 }
コード例 #9
0
        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("The requested Challenge resource doesn't exist.", System.Net.HttpStatusCode.NotFound);

            if (c.Privacy == (int)Challenge.ChallengePrivacy.FriendsOnly)
            {
                if (Security.DetermineAudience(c) < Security.Audience.Friends)
                    throw new HttpResponseException("This item is friends-only.", System.Net.HttpStatusCode.Forbidden);
            }

            if (BidRepo.CustomerDidBidOnChallenge(cust.ID, c.ID) != null)
                throw new HttpResponseException("You already bid on this challenge.", 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)Activity.ActivityType.ActivityBackDare, CustomerID = ((DareyaIdentity)HttpContext.Current.User.Identity).CustomerID };
            RepoFactory.GetActivityRepo().Add(activity);
        }