Esempio n. 1
0
        public TAG GetCommandeTag(Guid?id)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            TAG tag = db.TAGS.SingleOrDefault(x => x.tagId == id);

            return(tag);
        }
        public ActionResult FactureSearch(string searchValue)
        {
            if (searchValue != null && searchValue != "")
            {
                Session["Infosearch"] = searchValue;
            }
            else
            {
                return(View("ListFacture"));
            }

            redactapplicationEntities bds = new Models.redactapplicationEntities();
            Guid user = Guid.Parse(HttpContext.User.Identity.Name);

            Factures db     = new Factures();
            var      answer = db.SearchFacture(searchValue);

            if (answer == null || answer.Count == 0)
            {
                List <FACTUREViewModel> listeFacture = new List <FACTUREViewModel>();
                answer = listeFacture;
                ViewBag.SearchUserNoResultat = 1;
            }

            ViewBag.Search = true;
            redactapplicationEntities e = new redactapplicationEntities();

            List <FACTUREViewModel> listeDataFactureFiltered = new List <FACTUREViewModel>();

            ViewBag.listeFactureVm = answer;

            return(View("ListFacture"));
        }
Esempio n. 3
0
        public STATUT_COMMANDE GetStatutCommande(Nullable <System.Guid> id)
        {
            redactapplicationEntities db             = new Models.redactapplicationEntities();
            STATUT_COMMANDE           statutCommande = db.STATUT_COMMANDE.SingleOrDefault(x => x.statutCommandeId == id);

            return(statutCommande);
        }
Esempio n. 4
0
        public PROJET GetProjet(Guid?id)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            PROJET projet = db.PROJETS.SingleOrDefault(x => x.projetId == id);

            return(projet);
        }
Esempio n. 5
0
        public THEME GetTheme(Nullable <System.Guid> id)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            THEME theme = db.THEMES.SingleOrDefault(x => x.themeId == id);

            return(theme);
        }
Esempio n. 6
0
        public UTILISATEUR GetUtilisateur(Guid id)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            UTILISATEUR utilisateur      = db.UTILISATEURs.SingleOrDefault(x => x.userId == id);

            return(utilisateur);
        }
Esempio n. 7
0
        public CONTENU_TYPE GetCommandeContenuType(Guid?id)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            CONTENU_TYPE contenuType     = db.CONTENU_TYPE.SingleOrDefault(x => x.contenuTypeId == id);

            return(contenuType);
        }
Esempio n. 8
0
        public List <Guid> GetRelatedTheme(string theme)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            var themes = db.THEMES.Where(x => x.theme_name.Contains(theme)).Select(t => t.themeId).ToList();

            return(themes);
        }
Esempio n. 9
0
        /*pour aller a la page de modification du mot de passe*/
        public ActionResult UpdatePassword(Guid?token)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            UTILISATEUR utilisateur      = db.UTILISATEURs.SingleOrDefault(x => x.token == token);

            /*l'utilisateur est null si le token n'existe pas/plus dans la base de donnees*/
            if (utilisateur == null)
            {
                return(RedirectToAction("ExpiredLink", "Login"));
            }
            else
            {
                DateTime now = DateTime.Now;
                if (utilisateur.dateToken != null)
                {
                    DateTime dateToken = (DateTime)utilisateur.dateToken;
                    double   nbrTime   = (now - dateToken).TotalMinutes;
                    if (nbrTime > 60.0)
                    {
                        return(RedirectToAction("ExpiredLink", "Login"));
                    }
                }
            }
            Session["tokenPass"] = token;
            return(View());
        }
Esempio n. 10
0
        public SITE GetCommandeSite(Guid?id)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            SITE site = db.SITES.SingleOrDefault(x => x.siteId == id);

            return(site);
        }
Esempio n. 11
0
        public COMMANDE GetCommande(Guid?id)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            COMMANDE commande            = db.COMMANDEs.SingleOrDefault(x => x.commandeId == id);

            return(commande);
        }
Esempio n. 12
0
        public List <UTILISATEUR> GetRedateurOrderByTheme(string theme)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            var themesids = GetRelatedTheme(theme);
            var redactids = new List <Guid?>();

            foreach (var themeId in themesids)
            {
                var redactTheme = db.REDACT_THEME.FirstOrDefault(t => t.themeId == themeId);
                if (redactTheme != null)
                {
                    redactids.Add(redactTheme.redactId);
                }
            }


            // var redacteurs = db.UTILISATEURs.Where(u => redactids.Contains(u.userId)).OrderByDescending(n=>n.redactNiveau).ToList();


            var redacteurs = from c in db.UTILISATEURs
                             from p in db.UserRoles
                             where p.idUser == c.userId && p.idRole == 2
                             select c;

            var allredacteurs = redacteurs.OrderByDescending(n => n.redactNiveau).ToList();
            var redacteurSpec = db.UTILISATEURs.Where(u => redactids.Contains(u.userId)).OrderByDescending(n => n.redactNiveau).ToList();

            redacteurSpec.AddRange(allredacteurs);
            return(redacteurSpec.Distinct().ToList());
        }
        /*pour envoyer un mail de reset password a un utilisateur*/
        public ActionResult SendMail(UTILISATEURViewModel model)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            UTILISATEUR utilisateur      = db.UTILISATEURs.FirstOrDefault(x => x.userMail == model.userMail);
            Guid        TemporaryIdUser  = Guid.NewGuid();

            if (utilisateur == null)
            {
                return(View("ErrorUserNotExist"));
            }

            if (Request.Url != null)
            {
                var url = Request.Url.Scheme;
                if (Request.Url != null)
                {
                    string callbackurl = Request.Url.Host != "localhost"
                        ? Request.Url.Host
                        : Request.Url.Authority;
                    var port = Request.Url.Port;
                    if (!string.IsNullOrEmpty(port.ToString()) && Request.Url.Host != "localhost")
                    {
                        callbackurl += ":" + port;
                    }

                    url += "://" + callbackurl;
                }

                ViewBag.mailRecepteur = model.userMail;
                //var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                StringBuilder mailBody = new StringBuilder();
                mailBody.AppendFormat(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(utilisateur.userNom.ToLower()) + ",");
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat("<p>Votre avez récemment demandé de réinitialiser votre mot de passe pour le compte " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(utilisateur.userNom.ToLower()) + " .Cliquez sur le lien ci-dessous pour le réinitialiser.</p>");
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat(url + "/Login/UpdatePassword?token=" + TemporaryIdUser);
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat("<p> Si vous n'avez pas demandé la réinitialisation du mot de passe, ignorez cet e-mail. </p>");
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat("Codialement.");
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat("Media click App .");

                bool isSendMail = MailClient.SendMail(model.userMail, mailBody.ToString(), "Media click App - réinitialisation du mot de passe oublié.");
                if (isSendMail)
                {
                    utilisateur.token     = TemporaryIdUser;
                    utilisateur.dateToken = DateTime.Now;
                    int result = db.SaveChanges();
                    if (result <= 0)
                    {
                        return(View("ErrorConfiguration"));
                    }
                    return(View("SendMailSuccess", model));
                }
            }

            return(View("ErrorConfiguration"));
        }
        public ActionResult DeleteAllFactureSelected()
        {
            Guid userSession = new Guid(HttpContext.User.Identity.Name);

            ViewBag.userRole = (new Utilisateurs()).GetUtilisateurRoleToString(userSession);
            try
            {
                bool unique = true;
                if (Session["ListFactureToDelete"] != null)
                {
                    string      hash          = Session["ListFactureToDelete"].ToString();
                    List <Guid> listIdFacture = new List <Guid>();
                    if (!string.IsNullOrEmpty(hash))
                    {
                        if (!hash.Contains(','))
                        {
                            listIdFacture.Add(Guid.Parse(hash));
                        }
                        else
                        {
                            foreach (var id in (hash).Split(','))
                            {
                                listIdFacture.Add(Guid.Parse(id));
                            }
                            unique = false;
                        }
                    }
                    if (listIdFacture.Count != 0)
                    {
                        redactapplicationEntities db = new Models.redactapplicationEntities();
                        foreach (var factureId in listIdFacture)
                        {
                            //suppression des relations
                            //var commandes = db.COMMANDEs.Where(x => x.factureId == factureId);
                            //foreach (var cmde in commandes)
                            //{
                            //    cmde.factureId = null;
                            //    db.SaveChanges();
                            //}
                            //suppression des factures
                            FACTURE facture = db.FACTUREs.SingleOrDefault(x => x.factureId == factureId);
                            db.FACTUREs.Remove(facture);
                        }
                        db.SaveChanges();

                        if (unique)
                        {
                            return(View("DeletedFactureConfirmation"));
                        }
                        return(View("DeletedAllFactureConfirmation"));
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            return(View("ListFacture"));
        }
Esempio n. 15
0
        /*pour envoyer un mail de reset password a un utilisateur*/
        public ActionResult SendMail(UTILISATEURViewModel model)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            UTILISATEUR utilisateur      = db.UTILISATEURs.FirstOrDefault(x => x.userMail == model.userMail);
            Guid        TemporaryIdUser  = Guid.NewGuid();

            if (utilisateur == null)
            {
                return(View("ErrorUserNotExist"));
            }

            if (Request.Url != null)
            {
                var url = Request.Url.Scheme;
                if (Request.Url != null)
                {
                    string callbackurl = Request.Url.Host != "localhost"
                        ? Request.Url.Host
                        : Request.Url.Authority;
                    var port = Request.Url.Port;
                    if (!string.IsNullOrEmpty(port.ToString()) && Request.Url.Host != "localhost")
                    {
                        callbackurl += ":" + port;
                    }

                    url += "://" + callbackurl;
                }

                ViewBag.mailRecepteur = model.userMail;
                //var body = "<p>Email From: {0} ({1})</p><p>Message:</p><p>{2}</p>";
                StringBuilder mailBody = new StringBuilder();
                mailBody.AppendFormat("Dear " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(utilisateur.userNom.ToLower()));
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat("<p>Your recently requested to reset your password for your " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(utilisateur.userNom.ToLower()) + " account. Click the link bellow to reset it.</p>");
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat(url + "/Login/UpdatePassword?token=" + TemporaryIdUser);
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat("<p>If you did not request a password reset, please ignore this email. </p>");
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat("Thanks.");
                mailBody.AppendFormat("<br />");
                mailBody.AppendFormat("Mediaclick Company.");

                bool isSendMail = MailClient.SendResetPasswordMail(model.userMail, mailBody.ToString(), "Redact application - forgotten password.");
                if (isSendMail)
                {
                    utilisateur.token     = TemporaryIdUser;
                    utilisateur.dateToken = DateTime.Now;
                    int result = db.SaveChanges();
                    if (result <= 0)
                    {
                        return(View("ErrorConfiguration"));
                    }
                    return(View("SendMailSuccess", model));
                }
            }

            return(View("ErrorConfiguration"));
        }
Esempio n. 16
0
        public List <int> GetUtilisateurRole(Guid id)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            UTILISATEUR utilisateur      = db.UTILISATEURs.SingleOrDefault(x => x.userId == id);
            var         data             = (from idrole in db.UserRoles
                                            where idrole.idUser == utilisateur.userId
                                            select(int) idrole.idRole).ToList <int>();

            return(data);
        }
Esempio n. 17
0
        public List <string> GetThemes(Guid redactGuid)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            var themes = from c in db.THEMES
                         from p in db.REDACT_THEME
                         where p.themeId == c.themeId && p.redactId == redactGuid
                         select c.theme_name;

            return(themes.ToList());
        }
Esempio n. 18
0
        public ActionResult DeleteAllTemplateSelected()
        {
            Guid userSession = new Guid(HttpContext.User.Identity.Name);


            try
            {
                bool unique = true;
                if (Session["ListTemplateToDelete"] != null)
                {
                    string      hash           = Session["ListTemplateToDelete"].ToString();
                    List <Guid> listIdTemplate = new List <Guid>();
                    if (!string.IsNullOrEmpty(hash))
                    {
                        if (!hash.Contains(','))
                        {
                            listIdTemplate.Add(Guid.Parse(hash));
                        }
                        else
                        {
                            foreach (var id in (hash).Split(','))
                            {
                                listIdTemplate.Add(Guid.Parse(id));
                            }
                            unique = false;
                        }
                    }
                    if (listIdTemplate.Count != 0)
                    {
                        redactapplicationEntities db = new Models.redactapplicationEntities();
                        foreach (var templateId in listIdTemplate)
                        {
                            //suppression des commandes
                            TEMPLATE template = db.TEMPLATEs.SingleOrDefault(x => x.templateId == templateId);
                            if (template != null)
                            {
                                db.TEMPLATEs.Remove(template);
                            }
                        }
                        db.SaveChanges();

                        return(View(unique ? "DeleteTemplateConfirmation" : "DeteleAllTemplateConfirmation"));
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            return(RedirectToRoute("Home", new RouteValueDictionary {
                { "controller", "Template" },
                { "action", "ListTemplate" }
            }));
        }
Esempio n. 19
0
        public string RedactThemes(Guid redactGuid)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            var themes = from c in db.THEMES
                         from p in db.REDACT_THEME
                         where p.themeId == c.themeId && p.redactId == redactGuid
                         select c.theme_name;

            string themeredact = string.Join(",", themes.ToArray());

            return(themeredact);
        }
Esempio n. 20
0
        public List <UTILISATEUR> GetRedateurOrderByTheme(string theme)
        {
            redactapplicationEntities db = new Models.redactapplicationEntities();
            var themesids = GetRelatedTheme(theme);
            var redactids = db.REDACT_THEME.Where(r => themesids.Contains(r.themeId)).Select(t => t.userId).ToList();

            // var redacteurs = db.UTILISATEURs.Where(u => redactids.Contains(u.userId)).OrderByDescending(n=>n.redactNiveau).ToList();


            var redacteurs = from c in db.UTILISATEURs
                             from p in db.UserRoles
                             where p.idUser == c.userId && p.idRole == 2
                             select c;

            var allredacteurs = redacteurs.OrderByDescending(n => n.redactNiveau).ToList();
            var redacteurSpec = db.UTILISATEURs.Where(u => redactids.Contains(u.userId)).OrderByDescending(n => n.redactNiveau).ToList();

            redacteurSpec.AddRange(allredacteurs);
            return(redacteurSpec.Distinct().ToList());
        }
Esempio n. 21
0
        /*pour modifier le mot de passe*/
        public ActionResult ConfirmUpdatePassword(Guid?token, UTILISATEURViewModel model)
        {
            if (Session["tokenPass"] != null)
            {
                token = (Guid)Session["tokenPass"];
                Session["tokenPass"] = null;
            }
            string        patternNoAplha    = "[\\W]";
            string        patternDigit      = "[0-9]";
            string        patternAlphaUpper = "[A-Z]";
            string        patternAlphaLower = "[a-z]";
            List <string> Error             = new List <string>();

            ViewBag.ErrorPassWord = "";

            if (model.userMotdepasse == "")
            {
                Error.Add("The password entered is empty.");
            }
            if (model.userMotdepasseConfirme == "")
            {
                Error.Add("The confirmation password is empty.");
            }
            if (model.userMotdepasse != model.userMotdepasseConfirme)
            {
                Error.Add("The password entered and the confirmation password are not the same.");
            }
            if ((model.userMotdepasse.ToString().Length >= 8) == false)
            {
                Error.Add("The password must contain at least 8 characters.");
            }
            if ((Regex.IsMatch(model.userMotdepasse.ToString(), patternNoAplha)) == false)
            {
                Error.Add("The password must contain at least 1 non-alphanumeric character.");
            }
            if ((Regex.IsMatch(model.userMotdepasse.ToString(), patternDigit)) == false)
            {
                Error.Add("The password must contain at least 1 digit character.");
            }
            if ((Regex.IsMatch(model.userMotdepasse.ToString(), patternAlphaUpper)) == false)
            {
                Error.Add("The password must contain at least 1 uppercase character.");
            }
            if ((Regex.IsMatch(model.userMotdepasse.ToString(), patternAlphaLower)) == false)
            {
                Error.Add("The password must contain at least 1 lowercase character.");
            }
            if (Error.Count != 0)
            {
                Session["tokenPass"]  = token;
                ViewBag.userId        = token;
                ViewBag.ErrorPassWord = Error;
                return(View("ErrrorForgotPassword"));
            }
            redactapplicationEntities db = new Models.redactapplicationEntities();
            UTILISATEUR utilisateur      = db.UTILISATEURs.SingleOrDefault(x => x.token == token);

            if (utilisateur == null)
            {
                Error = new List <string> {
                    "You are no longer allowed to change your password."
                };
                Session["tokenPass"]  = token;
                ViewBag.userId        = token;
                ViewBag.ErrorPassWord = Error;
                return(View("ErrrorForgotPassword"));
            }
            utilisateur.userMotdepasse = Encryptor.EncryptPass(model.userMotdepasse);
            utilisateur.token          = null;
            utilisateur.dateToken      = null;
            db.SaveChanges();
            return(RedirectToAction("UpdatePasswordSuccess", "Login"));
        }
Esempio n. 22
0
        /*pour s'authentifier*/
        public ActionResult AuthentificationUser(UTILISATEURViewModel model)
        {
            try
            {
                string pwdCrypte             = model.userMotdepasse.Trim();
                redactapplicationEntities db = new Models.redactapplicationEntities();
                UTILISATEUR utilisateur      = null;
                if (model.saveOnComputer)
                {
                    utilisateur = db.UTILISATEURs.SingleOrDefault(x => x.userMail == model.userMail.Trim() && x.userMotdepasse == pwdCrypte);
                    if (utilisateur == null)
                    {
                        pwdCrypte = Encryptor.EncryptPass(pwdCrypte);
                    }
                }
                else
                {
                    pwdCrypte = Encryptor.EncryptPass(pwdCrypte);
                }


                utilisateur = db.UTILISATEURs.SingleOrDefault(x => x.userMail == model.userMail.Trim() && x.userMotdepasse == pwdCrypte);

                if (utilisateur != null)
                {
                    FormsAuthentication.SetAuthCookie(utilisateur.userId.ToString(), model.saveOnComputer);/*CREATION COOKIES*/
                    //Session["mail"] = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(utilisateur.userMail);
                    //Session["pass"] = pwdCrypte;
                    Session["logoUrl"] = utilisateur.logoUrl;
                    Session["name"]    = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(utilisateur.userNom);
                    Session["surname"] = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(utilisateur.userPrenom);
                    Session["role"]    = (new Utilisateurs()).GetUtilisateurRoleToString(utilisateur.userId);
                    if (model.saveOnComputer)
                    {
                        HttpCookie trigerAuths = new HttpCookie("trigerAuths");
                        trigerAuths.Values["username"] = utilisateur.userMail;
                        trigerAuths.Values["password"] = Encryptor.Decrypt(utilisateur.userMotdepasse);
                        trigerAuths.Expires            = DateTime.Now.AddDays(Convert.ToInt32(ConfigurationManager.AppSettings["cookiesValidity"]));
                        Response.Cookies.Add(trigerAuths);
                    }
                }
                else
                {
                    return(View("ErrorInvalidAccountOrPassword"));
                }
                var data = (new Utilisateurs()).GetUtilisateurRole(utilisateur.userId).ToList();
                {
                    if (data.Count == 1)
                    {
                        if (data[0] == 1)
                        {
                            return(RedirectToRoute("Home", new RouteValueDictionary
                            {
                                { "controller", "Contact" },
                                { "action", "ListeContact" }
                            }));
                        }
                        if (data[0] == 2)
                        {
                            return(RedirectToRoute("Home", new RouteValueDictionary {
                                { "controller", "Commandes" },
                                { "action", "ListCommandes" }
                            }));
                        }

                        if (data[0] == 4)
                        {
                            return(RedirectToRoute("Home", new RouteValueDictionary
                            {
                                { "controller", "Contact" },
                                { "action", "ListeContact" }
                            }));
                        }

                        if (data[0] == 3 || data[0] == 5)
                        {
                            return(RedirectToRoute("Home", new RouteValueDictionary {
                                { "controller", "Home" },
                                { "action", "ListeUser" },
                                { "numpage", 1 },
                                { "nbrow", 10 }
                            }));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Debug.WriteLine("passe exception");
                return(View("ErrorException"));
            }
            Debug.WriteLine("passe error final");
            return(View("ErrorInvalidAccountOrPassword"));
        }