//Ajouter un ticket
        public ActionResult Add()
        {
            if (User.Identity.IsAuthenticated)
            {
                TicketsAddViewModel ticket = new TicketsAddViewModel();

                ViewData["marchandID"] = marchandBox();
                return View(ticket);
            }
            return RedirectToAction("LogOn", "Profile");
        }
        public ActionResult Add(TicketsAddViewModel customModel)
        {
            if (customModel != null)
            {
                if (customModel.MarchandID == 0)
                {

                    if (customModel.MarchandID == 0 & customModel.Name != null & customModel.Url != null & customModel.Contact != null & customModel.Telephone != 0)
                    {
                        Marchand marchand = new Marchand()
                        {
                            Name = customModel.Name,
                            Url = customModel.Url,
                            Phone = customModel.Telephone,
                            ContactName = customModel.Contact,
                        };
                        MsiRepoMarchand.Add(marchand);
                        MsiRepoMarchand.Save();
                        customModel.MarchandID = MsiRepoMarchand.GetIdMarchand(customModel.Url).MarchandID;

                    }
                    else
                    {

                        ViewData["marchandID"] = marchandBox();
                        if (customModel.MarchandID == 0)
                        {
                            ModelState.AddModelError("choiceError", "Choisissez un marchand dans la liste déroulante ou ajouter un nouveau marchand à l'aide des champs");
                        }

                        if (customModel.Name == null)
                        {

                            ModelState.AddModelError("nameError", "vous devez entrer un nom");
                        }

                        if (customModel.Url == null)
                        {

                            ModelState.AddModelError("urlError", "vous devez entrer une URL");
                        }

                        if (customModel.Telephone == 0)
                        {

                            ModelState.AddModelError("phoneError", "vous devez rentrer un numéro de téléphone");
                        }

                        if (customModel.Contact == null)
                        {

                            ModelState.AddModelError("contactError", "vous devez rentrer le nom de votre contact technique");
                        }

                        return View("Add");
                    }
                }

                //customModel.ID_User = MsiRepoUser.GetUserByMail((User as CustomPrincipal).Mail).UserID;
                customModel.ID_User = MsiRepoUser.GetUser(User.Identity.Name).UserID;
                Ticket ticket = new Ticket()
                {
                    IDUser = customModel.ID_User,
                    Title = customModel.Title,
                    Summary = customModel.Summary,
                    Contents = customModel.Description,
                    DateCreation = DateTime.Now,
                    DateModification = DateTime.Now,
                    StateSolved = 0,
                    stateRead = 0,
                    IDMarchand = customModel.MarchandID
                };
                MsiRepoTicket.Add(ticket);
                MsiRepoTicket.Save();

                return View("CreateTicketSuccess");
            }
            else
                return View("NotFound");
        }
        public List<SelectListItem> marchandBox()
        {
            TicketsAddViewModel ticket = new TicketsAddViewModel();
            ticket.marchands = MsiRepoMarchand.GetAllMarchand();
            var marchanbox = new List<SelectListItem>();
            marchanbox.Add(new SelectListItem { Value = "0", Text = "Please choose" });
            foreach (var item in ticket.marchands)
            {
                marchanbox.Add(new SelectListItem { Value = item.MarchandID.ToString(), Text = item.Url });
            };

            return marchanbox;
        }