public ActionResult Create(int acid, int TemplateMasterId, string calledFrom = "") { LoginUserDetails objLoginUserDetails = (LoginUserDetails)InsiderTrading.Common.Common.GetSessionValue((string)ConstEnum.SessionValue.UserDetails); //CompaniesSL objCompaniesSL = new CompaniesSL(); ImplementedCompanyDTO objImplementedCompanyDTO = new ImplementedCompanyDTO(); TemplateMasterModel objTemplateMasterModel = new TemplateMasterModel(); List <PopulateComboDTO> lstList = new List <PopulateComboDTO>(); //TemplateMasterSL objTemplateMasterSL = new TemplateMasterSL(); TemplateMasterDTO objTemplateMasterDTO = new TemplateMasterDTO(); StringWriter objSignatureWriter = new StringWriter(); StringWriter objSubjectWriter = new StringWriter(); StringWriter objTemplateWriter = new StringWriter(); StringWriter objAddress1Writer = new StringWriter(); StringWriter objAddress2Writer = new StringWriter(); //get list of communication mode lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.CommunicationModes, null, null, null, null, true); if (TemplateMasterId == 0) { List <PopulateComboDTO> lstListForRules = new List <PopulateComboDTO>(); foreach (PopulateComboDTO objItem in lstList) { if (objItem.Key != ConstEnum.Code.CommunicationModeForFormE.ToString()) { lstListForRules.Add(objItem); } } ViewBag.CommunicationMode = lstListForRules; } else { ViewBag.CommunicationMode = lstList; } //get list of disclousre type lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.DisclosureType, null, null, null, null, true); ViewBag.DisclosureType = lstList; //get list of user type for letter type communicaiton mode lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.DisclosureLetterForUserType, ConstEnum.Code.CommunicationModeForLetter.ToString(), null, null, null, true); ViewBag.LetterFor = lstList; //get list of user type for FAQ type communicaiton mode lstList = FillComboValues(ConstEnum.ComboType.ListOfCode, ConstEnum.CodeGroup.DisclosureLetterForUserType, ConstEnum.Code.CommunicationModeForFAQ.ToString(), null, null, null, true); ViewBag.FAQFor = lstList; lstList = null; ViewBag.TemplateMasterId = TemplateMasterId; ViewBag.placeholderarr = "[]"; if (TemplateMasterId > 0) { using (var objTemplateMasterSL = new TemplateMasterSL()) { objTemplateMasterDTO = objTemplateMasterSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, TemplateMasterId); } InsiderTrading.Common.Common.CopyObjectPropertyByName(objTemplateMasterDTO, objTemplateMasterModel); if (objTemplateMasterModel.CommunicationModeCodeId == ConstEnum.Code.CommunicationModeForEmail) { objTemplateMasterModel.CommunicationFromEmail = objTemplateMasterModel.CommunicationFrom; } objTemplateMasterModel.Contents = objTemplateMasterModel.Contents.Replace("\\r\\n", Environment.NewLine); HttpUtility.HtmlDecode(objTemplateMasterModel.Contents, objContentsWriter); objTemplateMasterModel.Contents = objContentsWriter.ToString(); HttpUtility.HtmlDecode(objTemplateMasterModel.Subject, objSubjectWriter); objTemplateMasterModel.Subject = objSubjectWriter.ToString(); HttpUtility.HtmlDecode(objTemplateMasterModel.TemplateName, objTemplateWriter); objTemplateMasterModel.TemplateName = objTemplateWriter.ToString(); if (objTemplateMasterModel.CommunicationModeCodeId == Common.ConstEnum.Code.CommunicationModeForEmail) { List <string> lst = new List <string>(); MatchCollection mcol = Regex.Matches(objTemplateMasterModel.Contents, @"\|~\|(.*?)\|~\|"); foreach (Match m in mcol) { if (m != null && m.ToString() != "") { //objTemplateMasterModel.Contents = objTemplateMasterModel.Contents.Replace(m.ToString(), "[[[[" + m.ToString() + "]]]]"); objTemplateMasterModel.Contents = objTemplateMasterModel.Contents; } } } if (objTemplateMasterModel.CommunicationModeCodeId == Common.ConstEnum.Code.CommunicationModeForFormE) { List <string> lst = new List <string>(); MatchCollection matPlaceholderPattern1 = Regex.Matches(objTemplateMasterModel.Contents, @" \[(.*?)\]"); foreach (Match m in matPlaceholderPattern1) { if (m != null && m.ToString() != "") { objTemplateMasterModel.Contents = objTemplateMasterModel.Contents.Replace(m.ToString(), " [" + m.ToString().Trim() + "]"); } } MatchCollection matPlaceholderPattern2 = Regex.Matches(objTemplateMasterModel.Contents, @">(\[{1})(.*?)\]"); foreach (Match m in matPlaceholderPattern2) { //lst.Add(m.ToString()); if (m != null && m.ToString() != "") { string sPlaceHolderToReplace = m.ToString().Substring(1); objTemplateMasterModel.Contents = objTemplateMasterModel.Contents.Replace(m.ToString(), ">[" + sPlaceHolderToReplace.Trim() + "]"); } } } if (objTemplateMasterModel.Signature != null) { objTemplateMasterModel.Signature = objTemplateMasterModel.Signature.Replace("\\r\\n", Environment.NewLine); HttpUtility.HtmlDecode(objTemplateMasterModel.Signature, objSignatureWriter); objTemplateMasterModel.Signature = objSignatureWriter.ToString(); } if (objTemplateMasterModel.ToAddress1 != null) { objTemplateMasterModel.ToAddress1 = objTemplateMasterModel.ToAddress1.Replace("\\r\\n", Environment.NewLine); HttpUtility.HtmlDecode(objTemplateMasterModel.ToAddress1, objAddress1Writer); objTemplateMasterModel.ToAddress1 = objAddress1Writer.ToString(); } //for communcition type letter -- check if checkbox address 2 optional is checked or not // if checkbox is NOT checked then set null else replace new line character for text entered if (objTemplateMasterModel.CommunicationModeCodeId == ConstEnum.Code.CommunicationModeForLetter && !objTemplateMasterModel.IsCommunicationTemplate) { objTemplateMasterModel.ToAddress2 = null; } else { if (objTemplateMasterModel.ToAddress2 != null) { objTemplateMasterModel.ToAddress2 = objTemplateMasterModel.ToAddress2.Replace("\\r\\n", Environment.NewLine); HttpUtility.HtmlDecode(objTemplateMasterModel.ToAddress2, objAddress2Writer); objTemplateMasterModel.ToAddress2 = objAddress2Writer.ToString(); } } if (objTemplateMasterModel.CommunicationModeCodeId == ConstEnum.Code.CommunicationModeForFormE) { //Fetch the list of placeholders as per the communication mode lstList = FillComboValues(ConstEnum.ComboType.TemplateMasterPlaceholderList, objTemplateMasterModel.CommunicationModeCodeId.ToString(), null, null, null, null, false); List <string[]> arrPlaceholdersList = new List <string[]>(); foreach (var placeholder in lstList) { string[] arrPlaceholder = new string[1]; arrPlaceholder[0] = placeholder.Value; arrPlaceholdersList.Add(arrPlaceholder); } ViewBag.placeholderarr = JsonConvert.SerializeObject(arrPlaceholdersList).ToString(); } } else { using (var objCompaniesSL = new CompaniesSL()) { objImplementedCompanyDTO = objCompaniesSL.GetDetails(objLoginUserDetails.CompanyDBConnectionString, 0, 1); } //objTemplateMasterModel.CommunicationFrom = objImplementedCompanyDTO.EmailId; ViewBag.ImplementedCompanyEmailId = objImplementedCompanyDTO.EmailId; } ViewBag.CommunicationMode_id = objTemplateMasterModel.CommunicationModeCodeId; ViewBag.IsDisplayBackButton = true; ViewBag.calledFrom = calledFrom; ViewBag.acid = acid; if (calledFrom == "Communication") { ViewBag.IsDisplayBackButton = false; return(PartialView("Create", objTemplateMasterModel)); } else if (calledFrom == "CommunicationRule") { ViewBag.IsDisplayBackButton = false; return(PartialView("Create", objTemplateMasterModel)); } else { return(View("Create", objTemplateMasterModel)); } }