Example #1
0
        public bool SendSignupMail(IUserProfile user, string email, string password)
        {
            const string templateName = "Signup.txt";
            // const string mailTemplatePath = "~/MailTemplates/Signup.txt";
            bool IsHTML = templateName.Contains(".htm");

            MailAddress FromEMAILADDRESS = new MailAddress("*****@*****.**", "Inscription sur CoVoyage");
            string      ToEMAILADDRESS   = email;

            string SUBJECT = "Activation de votre compte CoVoyage";

            string MAILBODY      = this.LoadMailTemplate(templateName);
            string activationUrl = this.RefController.Url.CovCakeRouteUrl(CovCake.Routes.ACTIVATEACCOUNT, new { ac = user.ActivationKey.Value.Shrink() });

            MAILBODY = MAILBODY.Replace("#SITENAME#", CovCakeConfiguration.SiteName);
            MAILBODY = MAILBODY.Replace("#DISPLAYNAME#", user.Prenom);
            MAILBODY = MAILBODY.Replace("#EMAIL#", email);
            MAILBODY = MAILBODY.Replace("#PASSWORD#", password);
            MAILBODY = MAILBODY.Replace("#ACTIVATIONURL#", activationUrl);
            MAILBODY = MAILBODY.Replace("#TITLE#", SUBJECT);

            try
            {
                this.SendMail(FromEMAILADDRESS, ToEMAILADDRESS, SUBJECT, MAILBODY, IsHTML);
            }
            catch (Exception ex)
            {
                CovCake.Log.Exception.cError("SendSignupMail userId=" + CovCake.GetCurrentUserId().ToString(), ex);
                return(false);
            }
            return(true);
        }
        public static SelectList ListePays(string selectedPaysId, IList <string> listepays)
        {
            //IList<string> allPays = dataProvider.PaysDataAccess.GetAllPaysString();
            IList <IPays> allPaysE = (IList <IPays>)CovCake.UnCache("AllPays");

            if (allPaysE == null)
            {
                allPaysE = dataProvider.PaysDataAccess.GetAllPays().ToList();
                int cacheTime = CovCakeConfiguration.DefaultDataCacheExpiration;
                CovCake.Cache("AllPays", allPaysE, DateTime.Now.AddHours(cacheTime));
                // HttpRuntime.Cache.Insert("AllPays", allPaysE, null, DateTime.Now.AddHours(cacheTime), System.Web.Caching.Cache.NoSlidingExpiration);
            }
            int selPaysId = 77;

            if (!selectedPaysId.IsNullOrEmpty())
            {
                int.TryParse(selectedPaysId, out selPaysId);//france
            }
            foreach (string item in listepays)
            {
                IPays insertP = allPaysE.Single(p => p.LibellePays == item);
                allPaysE.Remove(insertP);
                allPaysE.Insert(0, insertP);
            }
            // allPays.Insert(0, "------------------------");
            if (selectedPaysId.IsNullOrEmpty())
            {
                return(new SelectList(allPaysE, "IdPays", "LibellePays"));        // selectedP);
            }
            return(new SelectList(allPaysE, "IdPays", "LibellePays", selPaysId)); // selectedP);
            //  return new SelectList(allPays, selectedPaysId);
        }
Example #3
0
        public bool SendSignupConfirmation(IUserProfile user, string email, string password)
        {
            const string templateName = "SignupConfirm.txt";
            // const string mailTemplatePath = "~/MailTemplates/Signup.txt";
            bool IsHTML = templateName.Contains(".htm");

            MailAddress FromEMAILADDRESS = new MailAddress("*****@*****.**", "Inscription sur CoVoyage");
            string      ToEMAILADDRESS   = email;

            string SUBJECT = "Bienvenue sur CoVoyage.net";

            string MAILBODY = this.LoadMailTemplate(templateName);

            // MAILBODY = MAILBODY.Replace("#SITENAME#", CovCakeConfiguration.SiteName);
            MAILBODY = MAILBODY.Replace("#DISPLAYNAME#", user.Prenom);
            MAILBODY = MAILBODY.Replace("#EMAIL#", email);
            MAILBODY = MAILBODY.Replace("#PASSWORD#", password);
            //  MAILBODY = MAILBODY.Replace("#TITLE#", SUBJECT);

            try
            {
                //   this.To.Add(new MailAddress(email));
                this.SendMail(FromEMAILADDRESS, ToEMAILADDRESS, SUBJECT, MAILBODY, IsHTML);
            }
            catch (Exception ex)
            {
                CovCake.Log.Exception.cError("SendSignupConfirmation userId=" + CovCake.GetCurrentUserId().ToString(), ex);
                return(false);
            }
            return(true);
        }
Example #4
0
        public bool SendNewMessageNotify(IMessagePrive msg)
        {
            const string templateName = "PrivateMessageNotify.txt";
            // const string mailTemplatePath = "~/MailTemplates/Signup.txt";

            bool   IsHTML        = templateName.Contains(".htm");
            string siteName      = CovCakeConfiguration.SiteName;
            string from          = CovCakeConfiguration.SiteNotifierEmail;
            string fromEmailName = siteName;
            string toEmail       = msg.ToUser.Email;
            string subject       = "CoVoyage.net : " + msg.FromUser.PrenomNom + " vous a envoyé un message sur CoVoyage";

            // msgResponseLink = CovCakeConfiguration.SiteUrl + msgResponseLink;
            // msgResponseLink = this.Url.CovCakeActionUrl("ShowMessage", "Messages", new RouteValueDictionary { { "MsgId", newMsgId } }, "http", CovCakeConfiguration.SiteName);

            string msgResponseLink = this.RefController.Url.CovCakeActionUrl("ShowMessage", "Messages", new { MsgId = msg.MsgId });

            string body = this.LoadMailTemplate(templateName);


            string relatedProjSentence = "";

            if (msg.ProjetRelatedId != null)
            {
                relatedProjSentence = "concernant le voyage " + msg.ProjetRelated.GetShortDisplayName();
            }


            body = body.Replace("#DISPLAYNAME#", msg.ToUser.Prenom);
            body = body.Replace("#SENDERDISPLAYNAME#", msg.FromUser.Prenom);

            body = body.Replace("#MESSAGE#", msg.TextMessage);
            body = body.Replace("#SUBJECT#", msg.SujetMessage);
            body = body.Replace("#SHOWMESSAGELINK#", msgResponseLink);

            body = body.Replace("#RELATEDTOPROJETSENTENCE#", relatedProjSentence);

            try
            {
                MailAddress fromAddress = new MailAddress(from, fromEmailName);
                //   this.To.Add(new MailAddress(email));
                this.SendMailAsync(fromAddress, toEmail, subject, body, IsHTML);
            }
            catch (Exception ex)
            {
                CovCake.Log.Exception.cError("SendNewMessageNotify userId=" + CovCake.GetCurrentUserId().ToString(), ex);
                return(false);
            }
            return(true);
        }
Example #5
0
        public static bool IsNewThread(this IMessagePrive msg)
        {
            //  throw new NotImplementedException();
            Guid currUserId = CovCake.GetCurrentUserId();

            if (msg.ToUserId == currUserId)
            {
                return(msg.IsToNewMessage);
            }
            else if (msg.FromUserId == currUserId)
            {
                return(msg.IsFromNewMessage);
            }
            else
            {
                throw new Exception("Ce message ne devrait pas concerner cet utilisateur (ni ToUser ni FromUser). UserId: " + currUserId.ToString());
            }
            //return (msg.MsgAnswers.NewMessagesFor(currUserId).Count() > 0);
            //  return (CovCake.DataProvider.MessageDataAccess.NewMessagesInThread(msg.MsgId, currUserId).Count() > 0);
        }
Example #6
0
        public bool SendChangeEmailMail(IUserProfile user, string newEmail)
        {
            const string templateName = "ChangeMail.txt";

            try
            {
                bool   IsHTML        = templateName.Contains(".htm");
                string fromEmail     = CovCakeConfiguration.SiteAdminEmail;
                string fromEmailName = "CoVoyage.net";
                string subject       = "CoVoyage: Changement d'adresse email";
                string toEmail       = newEmail;
                string body          = this.LoadMailTemplate(templateName);

                RouteValueDictionary linkValues = new RouteValueDictionary
                {
                    { "ak", user.ActivationKey.Value.Shrink() },
                    { "nm", newEmail.ShrinkForUrl() }
                };

                string confirmationUrl = this.RefController.Url.CovCakeActionUrl("SetNewMail", "Account", linkValues);

                body = body.Replace("#DISPLAYNAME#", user.Prenom);
                body = body.Replace("#NEWEMAIL#", newEmail);

                body = body.Replace("#ACTIVATIONURL#", confirmationUrl);


                var from = new MailAddress(fromEmail, fromEmailName);

                this.SendMailAsync(from, toEmail, subject, body, IsHTML);
            }
            catch (Exception ex)
            {
                CovCake.Log.Exception.cError("SendChangeEmailMail userId=" + CovCake.GetCurrentUserId().ToString(), ex);
                return(false);
            }
            return(true);
        }
Example #7
0
        public static IQueryable <IMessagePrive> NotDeleted(this IQueryable <IMessagePrive> query, TypeBoiteMessage boite)
        {
            //IQueryable<IMessagePrive> msgs;
            Guid currUserId = CovCake.GetCurrentUserId();

            switch (boite)
            {
            case TypeBoiteMessage.Inbox:
                return(query.Where(m => (m.InboxToUserThreadDel == false && m.ToUserId == currUserId) ||
                                   (m.InboxFromUserThreadDel == false && m.FromUserId == currUserId)));

                break;

            case TypeBoiteMessage.Outbox:
                return(query.Where(m => (m.OutboxToUserThreadDel == false && m.ToUserId == currUserId) ||
                                   (m.OutboxFromUserThreadDel == false && m.FromUserId == currUserId)));

                break;

            default:
                return(query);
            }
        }
Example #8
0
        public bool SendProjectResignNotify(IAbonnementProjet abo)
        {
            const string templateName = "ProjectResignNotify.htm";

            try
            {
                IUserProfile toUser        = abo.Projet.OwnerUserProfile;
                IUserProfile fromUser      = abo.UserProfile;
                bool         IsHTML        = templateName.Contains(".htm");
                string       siteName      = CovCakeConfiguration.SiteName;
                string       from          = CovCakeConfiguration.SiteNotifierEmail;
                string       fromEmailName = siteName;
                string       toEmail       = toUser.Email;
                string       subject       = "CoVoyage.net : " + fromUser.PrenomNom + " a quitté un de vos voyages";

                string subscriberUrl = this.RefController.Url.CovCakeActionUrl("Index", "User", new { userId = toUser.UserId });

                string ProfileLink = "<a href='" + subscriberUrl + "' >" + fromUser.PrenomNom + "</a>";

                string ProjetUrl  = this.RefController.Url.CovCakeActionUrl("Index", "Projets", new { projetId = abo.ProjetId });
                string ProjetLink = "<a href='" + ProjetUrl + "' >" + abo.Projet.GetLongDisplayName() + "</a>";

                string body = this.LoadMailTemplate(templateName);

                body = body.Replace("#DISPLAYNAME#", toUser.Prenom);
                body = body.Replace("#PROJETLONGNAMELINK#", ProjetLink);

                body = body.Replace("#SUBSCRIBERNAMELINK#", ProfileLink);

                MailAddress fromAddress = new MailAddress(from, fromEmailName);
                //   this.To.Add(new MailAddress(email));
                this.SendMailAsync(fromAddress, toEmail, subject, body, IsHTML);
            }
            catch (Exception ex)
            {
                CovCake.Log.Exception.cError(string.Format("{0} userid={1}", "SendProjectResignNotify", CovCake.GetCurrentUserId().ToString()), ex);
                return(false);
            }
            return(true);
        }
Example #9
0
 protected void ForceUserLogOut()
 {
     CovCake.LogoutCurrentUser();
     this._currentUser = null;
 }