public ActionResult PoserVotreQuestion() { ViewBag.SelectedClass = "mt1"; MessageModel messageModel = new MessageModel() { UserLogin = SessionManager.GetUserSession().UserLogin }; return View(messageModel); }
public ActionResult PoserVotreQuestion(MessageModel messageModel, HttpPostedFileBase uploadFile) { try { if (ModelState.IsValid) { string filePath = string.Empty; #region "Enregistrement Question dans la base" string ticket = StringHelper.RandomStringNumber(4, 4); User currentUser = SessionManager.GetUserSession(); Question question = new Question() { DateCreated = DateTime.Now, Email = currentUser.UserEmail, FirstName = currentUser.UserFirstName, Name = currentUser.UserName, Phone = currentUser.UserMobilePhone, idUser = currentUser.idUser, QuestionContent = messageModel.Content, Ticket = ticket }; db.Question.AddObject(question); db.SaveChanges(); #endregion #region "Gestion Fichier uploadé" if (uploadFile != null && uploadFile.ContentLength > 0) { DocumentType docType = DocumentTypeBL.GetDocumentTypeByCode(ElectronicSafeDocumentBL.DocumentType.SUPPORT.ToString()); string documentPath = string.Empty; documentPath = ElectronicSafeDocumentBL.BuildUserDocumentPath(docType.DocumentNamePrefix, currentUser); //TODO : to test string documentFullPath = System.IO.Path.Combine(ConfigurationManager.CoffreFortRootPath, documentPath); string filename = ElectronicSafeDocumentBL.BuildDocumentName(docType.DocumentNamePrefix, currentUser.idUser, uploadFile.FileName); // 1- Sauvegarde dans le repertoire filePath = System.IO.Path.Combine(documentFullPath, filename); uploadFile.SaveAs(filePath); } #endregion #region "Envoi mail" string sFrom = currentUser.UserEmail; string sTo = Upsilab.Business.Utility.ConfigurationManager.SupportEmailTo; string sSujet = LanguageData.GetContent("question_client"); string sMessage = string.Format(LanguageData.GetContent("expediteur_phone_email_question"), question.Name, question.FirstName, question.Phone, question.Email, question.QuestionContent); if (string.IsNullOrEmpty(filePath)) { EmailManager.SendEmail(sFrom, sTo, null, sSujet, sMessage); } else { EmailManager.SendEmail(sFrom, sTo, null, sSujet, sMessage, filePath, false); } //log EmailLogBL.Log(null, sFrom, null, sTo, EmailLogBL.TypeDestinataire.Client, System.Reflection.MethodBase.GetCurrentMethod().Name); #endregion ViewBag.MessageRetour = string.Format(LanguageData.GetContent("votre_question_a_bien_ete_transmise"), ticket); } else { //ModelState.AddModelError("", "L'envoi de question a échoué"); } ViewBag.SelectedClass = "mt1"; return View(messageModel); } catch (Exception ex) { ViewBag.MessageRetour = LanguageData.GetContent("erreur_catch") + ex.Message; return View(messageModel); } }
public ActionResult ProposerUneAmelioration() { ViewBag.SelectedClass = "mt4"; MessageModel messageModel = new MessageModel() { UserLogin = SessionManager.GetUserSession().UserLogin }; return View(messageModel); }