Пример #1
0
        /// <summary>
        /// Réalise l'inscription
        /// </summary>
        /// <param name="projetId"></param>
        /// <returns></returns>
        private IAbonnementProjet MakeSubscribtion(Guid UserId, int projetId)
        {
            //Si le mec est déja inscrit
            //au cas ou il refresh ou force en entrant l'url
            if (Data.AbonnementProjetDataAccess.GetAbonnement(UserId, projetId) != null)
            {
                return(null);
            }
            IAbonnementProjet abo = Data.AbonnementProjetDataAccess.CreateAbonnement();

            abo.DateAbonnement = DateTime.Now;
            abo.UserId         = UserId;
            abo.ProjetId       = projetId;

            IProjet proj = Data.ProjetDataAccess.GetProjet(projetId);

            try
            {
                using (TransactionScope trans = new TransactionScope())
                {
                    proj.UserAbonnesEntitySet.Add((cov_AbonnementProjet)abo);
                    Data.ProjetDataAccess.SubmitChanges();
                    trans.Complete();
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            return(abo);
        }
Пример #2
0
        /// <summary>
        /// Voyage vers {pays} le {date} avec {ownerDisplayname}
        /// </summary>
        /// <param name="proj"></param>
        /// <returns></returns>
        public static string GetFriendDisplayName(this IProjet proj)
        {
            int    nbSubscribers = proj.UserAbonnes.Count();
            string friendsLabel  = (nbSubscribers > 0) ? (++nbSubscribers) + " personnes" : proj.OwnerUserProfile.DisplayName;

            return("Voyage vers " + proj.GetShortDisplayName() + " avec " + friendsLabel);
        }
Пример #3
0
        public ActionResult SendMessages()
        {
            int SubscriberPageSize = 8;
            //PagedList<IUserProfile> subscriberList = null;// new PagedList<IUserProfile>(
            ////PagedList<IAbonnementProjet> aboList = new PagedList<IAbonnementProjet>(;
            //List<IAbonnementProjet> aboList = new List<IAbonnementProjet>();

            //foreach (var proj in  CurrentUser.Projets)
            //{
            //    IQueryable<IUserProfile> users = Data.AbonnementProjetDataAccess.GetAllAbonnements(proj.IdProjet).Select( abo => abo.UserProfile);
            //   // charger pr page Projet 1  only

            //}

            SendMessageViewData messageData = new SendMessageViewData();

            messageData.Subscribers = new List <IUserProfile>();
            IProjet firstProjet = CurrentUser.Projets.First();

            if (firstProjet != null)
            {
                messageData.Subscribers = Data.AbonnementProjetDataAccess.GetAllAbonnements(firstProjet.IdProjet).Select(abo => abo.UserProfile).ToList();
            }

            return(View(messageData));
        }
Пример #4
0
        public void Remove(int ProjetId)
        {
            IProjet proj = this.GetProjet(ProjetId);

            this._dataContext.cov_Projets.DeleteOnSubmit((cov_Projet)proj);
            this._dataContext.SubmitChanges();
        }
Пример #5
0
 /// <summary>
 /// Si date aujourdhui strict sup à date début projet
 /// </summary>
 /// <param name="proj"></param>
 /// <returns></returns>
 public static bool IsOutDated(this IProjet proj)
 {
     if (!proj.DateDebut.HasValue)
     {
         return(false);
     }
     return(DateTime.Now > proj.DateDebut);
 }
Пример #6
0
 /// <summary>
 /// {pays} le {date} ou {pays} ({nbJours} jours)
 /// </summary>
 /// <param name="proj"></param>
 /// <returns></returns>
 public static string GetShortDisplayName(this IProjet proj)
 {
     if (!proj.Incertain)
     {
         return(proj.PaysArrive.LibellePays + " le " + proj.DateDebut.Value.ToShortDateString());
     }
     return(proj.PaysArrive.LibellePays + " (" + proj.NbJours + " jours)");
 }
Пример #7
0
        public ActionResult SendMessage(int?pId, string toUid)
        {
            //ViewData["title"] = "Message";
            Guid ToUserId = toUid.ToGuid();

            if (pId == null && toUid == null)
            {
                ViewData["title"]   = "Messagerie";
                ViewData["message"] = "Impossible d'envoyer le message :(";
                return(PartialView("BlankModal"));
            }
            IUserProfile toUser        = null;
            IProjet      relatedProjet = null;

            if (ToUserId.IsEmpty() == false)
            {
                toUser = Data.UserDataAccess.GetUser(ToUserId);
                if (toUser == null)
                {
                    ViewData["message"] = "Ce message ne peut être envoyé au destinataire indiqué :( ";
                }
            }
            else if (pId.HasValue)
            {
                relatedProjet = Data.ProjetDataAccess.GetProjet(pId.Value);
                if (relatedProjet == null)
                {
                    ViewData["message"] = "Le projet concernant ce message est introuvable :( ";
                }
            }
            if (ViewData.ContainsKey("message"))
            {
                return(PartialView("BlankModal"));
            }
            SendMessageViewData sendMessageData = new SendMessageViewData();

            if (relatedProjet != null)
            {
                sendMessageData.RelatedProjet = relatedProjet;
                sendMessageData.ToUserProfile = relatedProjet.OwnerUserProfile;

                sendMessageData.relatedProjetId = relatedProjet.IdProjet.ToString();
                sendMessageData.toUserId        = relatedProjet.OwnerUserProfile.UserId.ToString();

                sendMessageData.sujet = "A propos du voyage n°" + sendMessageData.RelatedProjet.IdProjet + ": " + sendMessageData.RelatedProjet.GetShortDisplayName();
            }

            if (toUser != null)
            {
                sendMessageData.ToUserProfile = toUser;

                sendMessageData.toUserId = toUser.UserId.ToString();

                sendMessageData.sujet = "";
            }
            return(PartialView("SendMessageModal", sendMessageData));
        }
Пример #8
0
        public ActionResult Edit(int projetId)
        {
            IProjet proj = Data.ProjetDataAccess.GetProjet(projetId);

            if (proj == null)
            {
                return(RedirectToAction("MonCompte", "User"));
            }

            string /*transPrix = "0", resPrix = "0", resMaxHote = "0",*/ resType = "", modeTrans = "";
            double?  transPrix = null, resPrix = null;
            int?     resMaxHote = null;
            DateTime?dateDeb, dateFi;

            dateDeb = proj.DateDebut;
            dateFi  = proj.DateFin;// != null) ? proj.DateFin.Value.ToShortDateString() : "";

            if (proj.Residence != null)
            {
                resPrix = proj.Residence.Prix;
                if (proj.Residence.MaxHotes > 1)
                {
                    resMaxHote = proj.Residence.MaxHotes;
                }
                resType = proj.Residence.Type;
            }


            if (proj.Transports.Count() > 0)
            {
                ITransport trans = proj.Transports.First();
                modeTrans = trans.ModeTransport;
                transPrix = trans.PrixAR;;
            }
            int?nbjours = proj.NbJours;
            CreateProjetViewData projetViewData = new CreateProjetViewData()
            {
                adresse      = (proj.Residence != null) ? proj.Residence.Adresse : "",
                commentaires = proj.Commentaires,
                dateDebut    = dateDeb,
                dateFin      = dateFi,
                nbjours      = (proj.NbJours > 0) ? nbjours : null,
                villeArrive  = proj.VilleArrive,
                incertain    = bool.Parse(proj.Incertain.ToString().ToLower()),
                modetrans    = modeTrans,
                prixtrans    = transPrix,
                prixres      = resPrix,//(prresPrix > 0) ? proj.NbJours.ToString() : "",,
                typeres      = resType,
                maxhotes     = resMaxHote,

                Projet = proj
            };

            ViewData["title"] = "Editer mon voyage vers " + proj.PaysArrive.LibellePays;
            return(View(projetViewData));
        }
Пример #9
0
        private string GetDefaultMessageSubject(int projId)
        {
            IProjet proj = Data.ProjetDataAccess.GetProjet(projId);

            if (proj != null)
            {
                return("Message à propos du voyage n°" + projId + ": " + proj.GetShortDisplayName());
            }
            return("(Sans sujet)");
        }
Пример #10
0
 /// <summary>
 /// Si projet pas incertain retourne durée avant départ
 /// </summary>
 /// <param name="proj"></param>
 /// <returns></returns>
 public static TimeSpan GetTimeFromDeparture(this IProjet proj)
 {
     if (!proj.Incertain)
     {
         if (proj.DateDebut.HasValue)
         {
             return(proj.DateDebut.Value - DateTime.Now);
         }
     }
     return(TimeSpan.Zero);
 }
Пример #11
0
        public static string GetGeolocAddress(this IProjet proj)
        {
            string adr = "";

            if (proj.Residence != null)
            {
                adr = proj.Residence.Adresse;// +" " + proj.PaysArrive.CodePays + " " + proj.PaysArrive.LibellePays;
            }
            adr += (" " + proj.PaysArrive.CodePays + " " + proj.PaysArrive.LibellePays);
            return(adr);
        }
Пример #12
0
        public ActionResult CreateSuccess(int IdProjet)
        {
            IProjet proj = null;

            try
            {
                proj = Data.ProjetDataAccess.GetProjet((IdProjet));
            }
            catch (Exception)
            {
                return(View("Error"));
            }
            return(View("CreateSuccess", proj));
        }
Пример #13
0
        /// <summary>
        /// Affiche {depart -> paysArrivé} le {date} pendant {nbjours} jours
        /// </summary>
        /// <param name="proj"></param>
        /// <returns></returns>
        public static string GetLongDisplayName(this IProjet proj)
        {
            string villedep = (!string.IsNullOrEmpty(proj.VilleDepart)) ? proj.VilleDepart + " -> " : "";
            string dest     = villedep + proj.PaysArrive.LibellePays;

            if (!proj.Incertain)
            {
                return(dest + " le " + proj.DateDebut.Value.ToShortDateString() + " pendant " + proj.GetDuree());
            }
            else
            {
                return(dest + " pendant " + proj.NbJours + " jours");
            }
        }
Пример #14
0
        public ActionResult Delete(int projetId)
        {
            try
            {
                IProjet proj = Data.ProjetDataAccess.GetProjet(projetId);
                if (CurrentUserId == proj.OwnerUserId)
                {
                    Data.ProjetDataAccess.Remove(proj);

                    TempData["ViewInfos"] = new string[] { "Le voyage " + proj.GetShortDisplayName() + " a bien été supprimé" };
                }
            }
            catch (Exception ex)
            {
                Dictionary <string, string> modelError = new Dictionary <string, string>();
                modelError.Add("_FORM", "Le voyage n°" + projetId + " n'a pas pu être supprimé");
                TempData["ModelError"] = modelError;
            }


            return(RedirectToAction("MonCompte", "User"));
        }
Пример #15
0
        public ActionResult Edit(CreateProjetViewData newDataProjet)
        {
            /*
             * newDataProjet = new CreateProjetViewData()
             * {
             *  nbjours = "45",
             *  incertain = "true",
             *  details = "fhdzhenbdk",
             * // typeres = "HOTEL",
             *  typeres = "FAKE",
             *  prixres = "45,76",
             *
             *  modetrans = "FAKE",
             *  //modetrans = "TRAIN",
             *  adresse = "",
             *  prixtrans = "5",
             *  commentaires = "sale nbatar",
             *  projetid = "15"
             *
             * }; //
             */
            IProjet proj = UpdateProjet(newDataProjet);

            try
            {
                Data.ProjetDataAccess.SubmitChanges();
                SendProjetEditNotification(proj);
            }
            catch (ChangeConflictException lnkEx)
            {
            }
            catch (Exception ex)
            {
                ViewData["ErrorMsg"] = "Votre projet de voyage n'a pas pu être modifié."; //"Une erreur est survenue lors de l'envoi de l'email de confirmation. Si le probleme persiste veillez contacter " + Configuration.SiteAdminEmail + ".";
                return(View("Error"));
            }

            return(RedirectToRoute(CovCake.Routes.MONCOMPTE));//."MonCompte","User");// View("CreateSuccess");
        }
Пример #16
0
 public static GmapPoint GetLatLong(this IProjet proj)
 {
     /*
      * string adr = "";
      *
      * if(proj.Residence != null)
      * {
      *   adr = proj.Residence.Adresse + " " + proj.PaysArrive.CodePays + " " + proj.PaysArrive.LibellePays;
      * }
      *
      *
      * string[] csv =  {"0","0","0","0"};
      * try{
      *   csv = Services.GoogleMapServices.GetCSV(adr).Split(',');
      * }
      * catch(Exception ex)
      * {
      *
      * }
      * return new GmapPoint() { X = csv[2], Y = csv[3] };*/
     throw new NotImplementedException();
 }
Пример #17
0
        public bool SendProjetEditNotify(IProjet proj)
        {
            const string templateName = "ProjectEditNotify.htm";

            try
            {
                bool   IsHTML   = templateName.Contains(".htm");
                string siteName = CovCakeConfiguration.SiteName;
                string from     = CovCakeConfiguration.SiteNotifierEmail;
                string subject  = "CoVoyage.net : le voyage auquel vous participez a été modifié";

                string fromEmailName = siteName;
                string toEmail;

                string body = this.LoadMailTemplate(templateName);

                string projetUrl  = this.RefController.Url.CovCakeActionUrl("Index", "Projets", new { projetId = proj.IdProjet });
                string projetLink = "<a href='" + projetUrl + "' >" + proj.GetLongDisplayName() + "</a>";

                string projetOwnerUrl  = this.RefController.Url.CovCakeRouteUrl(CovCake.Routes.USERINDEX, new { userId = proj.OwnerUserProfile.UserId.Shrink() });
                string projetOwnerLink = "<a href='" + projetOwnerUrl + "' >" + proj.OwnerUserProfile.PrenomNom + "</a>";

                body = body.Replace("#PROJETLONGNAMELINK#", projetLink);
                body = body.Replace("#PROJETOWNERNAMELINK#", projetOwnerLink);
                foreach (var abo in proj.UserAbonnes)
                {
                    body    = body.Replace("#DISPLAYNAME#", abo.UserProfile.Prenom);
                    toEmail = abo.UserProfile.Email;
                    this.SendMailAsync(new MailAddress(from, fromEmailName), toEmail, subject, body, IsHTML);
                }
            }
            catch (Exception ex)
            {
                CovCake.Log.Exception.cError("SendProjetEditNotify Error. IdProjet=" + proj.IdProjet.ToString(), ex);
                return(false);
            }
            return(true);
        }
Пример #18
0
        //Send Email notification !!!

        #region Send email notififcation

        private void SendProjetEditNotification(IProjet proj)
        {
            CovCakeMailer.SendProjetEditNotify(proj);
        }
Пример #19
0
        /// <summary>
        /// retourne {paysArrive} ({villeArrive})
        /// </summary>
        /// <param name="proj"></param>
        /// <returns></returns>
        public static string GetProjectTitle(this IProjet proj)
        {
            string villeString = (!proj.VilleArrive.IsNullOrEmpty()) ? " (" + proj.VilleArrive + ")" : "";

            return(proj.PaysArrive.LibellePays + villeString);
        }
Пример #20
0
 public static string ProjetIndexLink(this HtmlHelper htmlHelper, string text, IProjet proj)
 {
     return(htmlHelper.ProjetIndexLink(text, proj, null));
 }
Пример #21
0
 public static string ProjetIndexLink(this HtmlHelper htmlHelper, string text, IProjet proj, object htmlAttributes)
 {
     return(htmlHelper.RouteLink(text, CovCake.Routes.PROJETINDEX, new { ProjetId = proj.IdProjet }, htmlAttributes));
 }
Пример #22
0
 public void Remove(IProjet proj)
 {
     this._dataContext.cov_Projets.DeleteOnSubmit((cov_Projet)proj);
     this._dataContext.SubmitChanges();
 }
Пример #23
0
 public void InsertProjet(IProjet proj)
 {
     this._dataContext.cov_Projets.InsertOnSubmit((cov_Projet)proj);
     this._dataContext.SubmitChanges();
 }
Пример #24
0
 public static string GetDisplayName(this IProjet proj)
 {
     return(proj.GetProjectTitle() + " pendant " + proj.GetDuree().ToString());
 }
Пример #25
0
 /// <summary>
 /// Reoutrne DateDebut.ToShortDateString() ou la chaine passé en paramettre si null
 /// </summary>
 /// <param name="proj"></param>
 /// <param name="replaceText"></param>
 /// <returns></returns>
 public static string GetShortDateStringOr(this IProjet proj, string replaceText)
 {
     return((proj.DateDebut.HasValue) ? proj.DateDebut.Value.ToShortDateString() : replaceText);
 }
Пример #26
0
 public static string VoyageDestination(this HtmlHelper htmlHelper, IProjet proj)
 {
     return("");
 }
 public static IQueryable <IAbonnementProjet> GetAllAbonnementTo(this IQueryable <IAbonnementProjet> query, IProjet projet)
 {
     return((from A in query
             where A.ProjetId == projet.IdProjet
             select A).Cast <IAbonnementProjet>());
 }
Пример #28
0
 /// <summary>
 /// Renvoi DateDebut.ToShortDateString() ou la chaine "Incertain" si null
 /// </summary>
 /// <param name="proj"></param>
 /// <returns></returns>
 public static string GetShortDateStringOr(this IProjet proj)
 {
     return((proj.DateDebut.HasValue) ? proj.DateDebut.Value.ToShortDateString() : "Incertain");
 }
Пример #29
0
 /// <summary>
 /// Indique si User participe au projet projId
 /// </summary>
 /// <param name="user"></param>
 /// <param name="proj"></param>
 /// <returns></returns>
 public static bool ParticipeA(this IUserProfile user, IProjet proj)
 {
     return(ParticipeA(user, proj.IdProjet));
 }
Пример #30
0
 /// <summary>
 /// Retourne DateDebut.ToShortDateString() ou GetDuree().ToString() si null
 /// </summary>
 /// <param name="proj"></param>
 /// <returns></returns>
 public static string GetShortDateStringOrDuration(this IProjet proj)
 {
     return((proj.DateDebut.HasValue) ? proj.DateDebut.Value.ToShortDateString() : proj.GetDuree().ToString());
 }