public void OwnerModifyAffiliations(Jid to, Jid from, string node, Affiliate[] affiliates, IqCB cb, object cbArgs) { var pubsubIq = new owner.PubSubIq(IqType.set, to); if (from != null) { pubsubIq.From = from; } var affs = new Affiliates(node); affs.AddAffiliates(affiliates); pubsubIq.PubSub.Affiliates = affs; if (cb == null) { m_connection.Send(pubsubIq); } else { m_connection.IqGrabber.SendIq(pubsubIq, cb, cbArgs); } }
public override long?GetCurrentAffiliateId() { long?affiliateId = null; var dnnUser = DnnUserController.Instance.GetCurrentUserInfo(); if (dnnUser != null) { affiliateId = GetProfileAffiliateId(dnnUser); } if (!affiliateId.HasValue) { affiliateId = SessionManager.CurrentAffiliateID(Context.CurrentStore); } if (affiliateId.HasValue) { var aff = Affiliates.Find(affiliateId.Value); if (aff != null && aff.Enabled && aff.Approved) { return(affiliateId); } } return(null); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirtsName,LastName,NationalId,Birthday,Gender")] Affiliates affiliates) { if (id != affiliates.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(affiliates); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AffiliatesExists(affiliates.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(affiliates)); }
private bool SetNewAffiliate(string referrerId, string referrerUrl, MerchantTribeApplication app) { Contacts.Affiliate aff = Affiliates.FindByReferralId(referrerId); if (aff == null) { return(false); } if (!aff.Enabled) { return(false); } if (aff.Id != SessionManager.CurrentAffiliateID(app.CurrentStore)) { System.DateTime expires = System.DateTime.UtcNow; if (aff.ReferralDays > 0) { TimeSpan ts = new TimeSpan(aff.ReferralDays, 0, 0, 0); expires = expires.Add(ts); } else { expires = System.DateTime.UtcNow.AddYears(50); } SessionManager.SetCurrentAffiliateId(aff.Id, expires, app.CurrentStore); } return(LogReferral(aff.Id, referrerUrl)); }
public async Task <IActionResult> Create([Bind("Id,FirtsName,LastName,NationalId,Birthday,Gender")] Affiliates affiliates) { if (ModelState.IsValid) { _context.Add(affiliates); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(affiliates)); }
protected bool LogReferral(long affiliateId, string referrerUrl) { var aff = Affiliates.Find(affiliateId); if (aff != null && aff.Enabled && aff.Approved) { var r = new AffiliateReferral(); r.AffiliateId = aff.Id; r.ReferrerUrl = referrerUrl; return(AffiliateReferrals.Create(r)); } return(false); }
// Returns -1 on failure, or the role of the user. public int RoleFor(ApplicationUser user) { if (user == null) { return(-1); } var tag = Affiliates.Where(a => a.ApplicationUserId == user.Id).FirstOrDefault(); if (tag == null) { return(-1); } return(tag.Role); }
private bool LogReferral(long affiliateId, string referrerUrl) { Contacts.Affiliate aff = Affiliates.Find(affiliateId); if (aff == null) { return(false); } if (!aff.Enabled) { return(false); } AffiliateReferral r = new AffiliateReferral(); r.AffiliateId = aff.Id; r.ReferrerUrl = referrerUrl; return(AffiliateReferrals.Create(r)); }
public override void SetAffiliateReferral(string affiliateId, string referralUrl) { var store = Context.CurrentStore; var currentAffId = GetCurrentAffiliateId(); // Replace AffiliateId if Mode is Force New Affiliate var replaceAffiliateId = !currentAffId.HasValue || (store.Settings.AffiliateConflictMode == AffiliateConflictMode.FavorNewAffiliate); if (replaceAffiliateId) { var aff = Affiliates.FindByAffiliateId(affiliateId); if (aff != null && aff.Enabled && aff.Approved) { if (aff.Id != currentAffId) { var expireDate = DateTime.UtcNow; if (aff.ReferralDays > 0) { expireDate = expireDate.AddDays(aff.ReferralDays); } else { expireDate = DateTime.UtcNow.AddYears(50); } var dnnUser = DnnUserController.Instance.GetCurrentUserInfo(); if (dnnUser != null) { SetProfileAffiliateId(dnnUser, aff.Id, expireDate); } SessionManager.SetCurrentAffiliateId(aff.Id, expireDate); } LogReferral(aff.Id, referralUrl); } } else { LogReferral(currentAffId.Value, referralUrl); } }
public long GetValidAffiliateId(MerchantTribeApplication app) { long current = SessionManager.CurrentAffiliateID(app.CurrentStore); if (current < 0) { return(0); } Contacts.Affiliate aff = Affiliates.Find(current); if (aff == null) { return(0); } if (!aff.Enabled) { return(0); } return(current); }
public override void UpdateProfileAffiliateId(long affiliateId) { var aff = Affiliates.Find(affiliateId); if (aff != null && aff.Enabled && aff.Approved) { var expireDate = DateTime.UtcNow; if (aff.ReferralDays > 0) { expireDate = expireDate.AddDays(aff.ReferralDays); } else { expireDate = DateTime.UtcNow.AddYears(50); } var dnnUser = DnnUserController.Instance.GetCurrentUserInfo(); if (dnnUser != null) { SetProfileAffiliateId(dnnUser, aff.Id, expireDate); } } }
public IEnumerable <ApplicationUser> GetStudents() { return(Affiliates.Where(c => c.Role == CourseJoinTag.ROLE_STUDENT).Select(cjt => cjt.ApplicationUser)); }
public IEnumerable <ApplicationUser> GetInstructors() { return(Affiliates.Where(c => c.Role == CourseJoinTag.ROLE_INSTRUCTOR).Select(cjt => cjt.ApplicationUser)); }