public bool CanManipulateContent(Challenge c) { if (!HttpContext.Current.User.Identity.IsAuthenticated) return false; if (c.Privacy == (int)Challenge.ChallengePrivacy.SinglePerson) { if (c.TargetCustomerID == ((Models.DareyaIdentity)HttpContext.Current.User.Identity).CustomerID) return true; else return false; } Audience a = CoreDetermineAudience(((Models.DareyaIdentity)HttpContext.Current.User.Identity).CustomerID); switch (a) { case Audience.Users: //if (c.Privacy == (int)Challenge.ChallengePrivacy.FriendsOnly) // return false; return true; case Audience.Owner: return true; case Audience.Friends: return true; case Audience.Anybody: default: return false; } }
public void AddBidToChallenge(Challenge item, long lCustomerID, decimal dBidAmount, decimal dComputedFees) { using (SqlConnection db = new SqlConnection(connStr)) { db.Open(); db.Execute("AddBidToChallenge", new { ChallengeID = item.ID, BidAmount = dBidAmount, CustomerID = lCustomerID, FeesAmount = dComputedFees }, commandType: CommandType.StoredProcedure); } }
public long Add(Challenge item) { Database.Challenge c = ChallengeToDbChallenge(item, false); repo.Challenge.AddObject(c); repo.SaveChanges(); repo.Refresh(System.Data.Objects.RefreshMode.StoreWins, c); repo.Detach(c); return c.ID; }
public long Add(Challenge item) { using (SqlConnection conn = new SqlConnection(connStr)) { conn.Open(); DynamicParameters p = ChalToDynParm(item); p.Add("@InsertID", dbType: DbType.Int64, direction: ParameterDirection.Output); conn.Execute("spChallengeAdd", p, commandType: CommandType.StoredProcedure); return p.Get<long>("InsertID"); } }
public static Dictionary<string, long> GetNotifyQueueMessageData(NotifyType emailType, Customer Source, Customer Target, Challenge Challenge) { Dictionary<string, long> data = new Dictionary<string, long>(); data.Add("nType", (long)emailType); if(Source!=null) data.Add("SrcID", Source.ID); if(Target!=null) data.Add("TgtID", Target.ID); if(Challenge!=null) data.Add("ChaID", Challenge.ID); return data; }
public decimal ComputeActualBountyForChallenge(Challenge c) { // break even vig = decimal contributedBounty; /* * * total up RealizedBidAmount (this is the ActualBid-FeesPaid) * then * TotalRealizedBidAmount=(RealizedBidAmount*TheVig()) * * */ return 0; }
public bool Update(Challenge item) { Database.Challenge c = ChallengeToDbChallenge(item); /* Database.Challenge c = repo.Challenge.FirstOrDefault(d => d.ID == item.ID); //c.Anonymous = item.Anonymous; c.CurrentBid = item.CurrentBid; c.CustomerID = item.CustomerID; c.Description = item.Description; c.Privacy = (byte)item.Privacy; c.State = item.State; c.Title = item.Title; c.TargetCustomerID = item.TargetCustomerID; */ repo.SaveChanges(); return true; }
public void AddBidToChallenge(Challenge item, long CustomerID, decimal BidAmount, decimal ComputedFees) { repo.AddBidToChallenge(item.ID, BidAmount, CustomerID, ComputedFees); }
/// <summary> /// Create a new Challenge object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="customerID">Initial value of the CustomerID property.</param> public static Challenge CreateChallenge(global::System.Int64 id, global::System.String title, global::System.String description, global::System.Int64 customerID) { Challenge challenge = new Challenge(); challenge.ID = id; challenge.Title = title; challenge.Description = description; challenge.CustomerID = customerID; return challenge; }
private Challenge DbChallengeToChallenge(Database.Challenge dc) { Challenge c = new Challenge(); c.ID = dc.ID; c.Title = dc.Title; c.Description = dc.Description; c.CurrentBid = (int)dc.CurrentBid; c.Privacy = (int)dc.Privacy; c.State = (int)dc.State; c.TargetCustomerID = (int)dc.TargetCustomerID; c.CustomerID = dc.CustomerID; try { c.Visibility = Convert.ToInt32(dc.Visibility); } catch (Exception ex) { c.Visibility = 0; } return c; }
public Disposition DetermineDisposition(Challenge c) { if (!HttpContext.Current.User.Identity.IsAuthenticated) return Disposition.None; long curCustID=((Models.DareyaIdentity)HttpContext.Current.User.Identity).CustomerID; if(c.CustomerID==curCustID) return Disposition.Originator; if(c.TargetCustomerID==curCustID) return Disposition.Taker; if(RepoFactory.GetChallengeBidRepo().CustomerDidBidOnChallenge(curCustID, c.ID)!=null) return Disposition.Backer; if (RepoFactory.GetChallengeStatusRepo().CustomerTookChallenge(curCustID, c.ID)) return Disposition.Taker; return Disposition.None; }
public static void NotifyChallengeYouBackedAwardedDissented(Customer Target, Challenge Challenge) { RepoFactory.GetProcessingQueue().PutQueueMessage(ProcessingQueue.MessageType.Notify, GetNotifyQueueMessageData(NotifyType.ChallengeYouBackedAwardedDissented, null, Target, Challenge)); }
public Audience DetermineVisibility(Challenge c) { return Audience.Users; }
private DynamicParameters ChalToDynParm(Challenge c, bool inclID = false) { var p = new DynamicParameters(); p.Add("@Description", c.Description, DbType.String, ParameterDirection.Input); p.Add("@Privacy", c.Privacy, DbType.Int32, ParameterDirection.Input); p.Add("@Visibility", c.Visibility, DbType.Int32, ParameterDirection.Input); p.Add("@State", c.State, DbType.Int32, ParameterDirection.Input); p.Add("@Anonymous", c.Anonymous, DbType.Int32, ParameterDirection.Input); p.Add("@CustomerID", c.CustomerID, DbType.Int64, ParameterDirection.Input); p.Add("@TargetCustomerID", c.TargetCustomerID, DbType.Int64, ParameterDirection.Input); if (inclID) p.Add("@ID", c.ID, DbType.Int64, ParameterDirection.Input); return p; }
public Audience DetermineAudience(Challenge c) { return CoreDetermineAudience(c.CustomerID); }
private Database.Challenge ChallengeToDbChallenge(Challenge c, bool Attach=true) { Database.Challenge dc = new Database.Challenge(); dc.ID = c.ID; if(Attach) repo.Challenge.Attach(dc); dc.Title = c.Title; dc.Description = c.Description; dc.CustomerID = c.CustomerID; dc.Privacy = (byte)c.Privacy; dc.State = c.State; dc.TargetCustomerID = c.TargetCustomerID; dc.CurrentBid = c.CurrentBid; dc.Visibility = c.Visibility; return dc; }
/// <summary> /// Deprecated Method for adding a new object to the Challenge EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToChallenge(Challenge challenge) { base.AddObject("Challenge", challenge); }
public static void NotifyNewChallenge(Customer Source, Customer Target, Challenge Challenge) { RepoFactory.GetProcessingQueue().PutQueueMessage(ProcessingQueue.MessageType.Notify, GetNotifyQueueMessageData(NotifyType.NewChallenge, Source, Target, Challenge)); }
public bool Update(Challenge item) { using (SqlConnection conn = new SqlConnection(connStr)) { conn.Open(); DynamicParameters p = ChalToDynParm(item, true); return (conn.Execute("spChallengeUpdate", p, commandType: CommandType.StoredProcedure) != 0); } }
private Challenge PrepOutboundChallenge(Challenge c) { if (c == null) return null; Customer tempCust = CustRepo.GetWithID(c.CustomerID); c.Customer = (Customer)Customer.Filter(tempCust); tempCust = null; if (c.TargetCustomerID > 0) { Customer tempTargetCust = CustRepo.GetWithID(c.TargetCustomerID); if (tempTargetCust!=null && tempTargetCust.FirstName != null && !tempTargetCust.FirstName.Equals("")) { c.TargetCustomer = (Customer)Customer.Filter(tempTargetCust); } tempTargetCust = null; } c.Disposition = (int)Security.DetermineDisposition(c); try { if (c.Disposition == (int)Security.Disposition.Taker) c.Status = StatusRepo.Get(((DareyaIdentity)HttpContext.Current.User.Identity).CustomerID, c.ID); else if (c.Disposition == (int)Security.Disposition.Backer || c.Disposition==(int)Security.Disposition.Originator) c.Bid = BidRepo.CustomerDidBidOnChallenge(((DareyaIdentity)HttpContext.Current.User.Identity).CustomerID, c.ID); } catch (Exception e) { } c.NumberOfBidders = BidRepo.GetBidCountForChallenge(c.ID);//BidRepo.Get(c.ID).Count; c.NumberOfTakers = StatusRepo.GetActiveStatusesForChallenge(c.ID).Count; return c; }