Exemplo n.º 1
0
        // **************************************
        // CreateNewInvitation
        // **************************************
        public static Guid CreateNewInvitation(string inviteEmailAddress)
        {
            using (var ctx = new SongSearchContext()) {
                inviteEmailAddress = inviteEmailAddress.ToLower();
                var userId = Account.User().UserId;
                var inv = ctx.Invitations.SingleOrDefault(
                    i => i.InvitationEmailAddress.ToLower() == inviteEmailAddress.ToLower()
                    && i.InvitationStatus == (int)InvitationStatusCodes.Open
                    && i.InvitedByUserId == userId);

                if (inv == null) {
                    inv = new Invitation {
                        InvitationId = Guid.NewGuid(),
                        InvitationEmailAddress = inviteEmailAddress,
                        ExpirationDate = DateTime.Now.AddDays(30).Date,
                        InvitedByUserId = userId,
                        InvitationStatus = (int)InvitationStatusCodes.Open,
                        IsPlanInvitation = !Account.User().IsSuperAdmin() //if it's a member admin, count against their user quota
                    };

                    ctx.Invitations.AddObject(inv);
                } else {//extend expiration date

                    //inv.InvitationStatus = (int)InvitationStatusCodes.Open;
                    inv.ExpirationDate = DateTime.Now.AddDays(30).Date;

                }

                ctx.SaveChanges();

                return inv.InvitationId;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Invitations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToInvitations(Invitation invitation)
 {
     base.AddObject("Invitations", invitation);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new Invitation object.
 /// </summary>
 /// <param name="invitationId">Initial value of the InvitationId property.</param>
 /// <param name="invitationEmailAddress">Initial value of the InvitationEmailAddress property.</param>
 /// <param name="expirationDate">Initial value of the ExpirationDate property.</param>
 /// <param name="invitationStatus">Initial value of the InvitationStatus property.</param>
 /// <param name="invitedByUserId">Initial value of the InvitedByUserId property.</param>
 /// <param name="isPlanInvitation">Initial value of the IsPlanInvitation property.</param>
 public static Invitation CreateInvitation(global::System.Guid invitationId, global::System.String invitationEmailAddress, global::System.DateTime expirationDate, global::System.Int16 invitationStatus, global::System.Int32 invitedByUserId, global::System.Boolean isPlanInvitation)
 {
     Invitation invitation = new Invitation();
     invitation.InvitationId = invitationId;
     invitation.InvitationEmailAddress = invitationEmailAddress;
     invitation.ExpirationDate = expirationDate;
     invitation.InvitationStatus = invitationStatus;
     invitation.InvitedByUserId = invitedByUserId;
     invitation.IsPlanInvitation = isPlanInvitation;
     return invitation;
 }
Exemplo n.º 4
0
        // **************************************
        // CreateUser
        // **************************************
        internal static User Create(this SongSearchContext ctx, User user, Invitation inv, PricingPlan pricingPlan)
        {
            var newUser = new User() {
                UserName = user.UserName,
                FirstName = user.FirstName,
                LastName = user.LastName,
                HasAgreedToPrivacyPolicy = user.HasAgreedToPrivacyPolicy,
                HasAllowedCommunication = user.HasAllowedCommunication,
                Password = user.Password.PasswordHashString(),
                ParentUserId = inv.InvitedByUserId > 0 ? inv.InvitedByUserId : _defaultUserId,
                PlanUserId = inv.InvitedByUser != null ? inv.InvitedByUser.UserId : _defaultUserId, //default placeholder;_defaultUserId; //default placeholder;
                PricingPlanId = pricingPlan.PricingPlanId,
                PlanBalanceId = inv.InvitedByUser != null ? inv.InvitedByUser.PlanBalanceId : _defaultUserId, //default placeholder;

                //// Members are Clients until promoted, new plans are admins from the start:
                //RoleId = inv.IsPlanInvitation ? (int)Roles.Client : (int)Roles.Admin,
                RoleId = (int)Roles.Admin, //making all new invitees admins from the start

                //user.PricingPlanId = (int)PricingPlans.Basic;
                SiteProfileId = inv.InvitedByUser.SiteProfileId,// int.Parse(SystemConfig.DefaultSiteProfileId);
                RegisteredOn = DateTime.Now,
                InvitationId = inv.InvitationId
            };
            //create user to get a userid
            ctx.Users.AddObject(newUser);

            return newUser;
        }