public IHttpActionResult AddSupportTicket(AddSupportTicketRequest addSupportTicketRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var supportTicket = new SupportTicket() { UserId = Utility.UserId, TopicId = addSupportTicketRequest.TopicId, SubTopicId = addSupportTicketRequest.SubTopicId, QueryTitle = addSupportTicketRequest.QueryTitle, DepartmentId = addSupportTicketRequest.DepartmentId, Query = addSupportTicketRequest.Query, CreatedBy = Utility.UserId }; int result = iSupportTicket.AddSupportTicket(supportTicket); if (result > 0) { responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "Post query added successfully."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding post query."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding post query."; Utility.WriteLog("AddSupportTicket", addSupportTicketRequest, "Error while adding supportticket. (SupportTicketAdminController)", ex.ToString()); } return(Ok(responses)); }
public IHttpActionResult AddSupportTicket(AddSupportTicketRequest addSupportTicketRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var supportTicket = new SupportTicket() { UserId = Utility.UserId, TopicId = addSupportTicketRequest.TopicId, SubTopicId = addSupportTicketRequest.SubTopicId, QueryTitle = addSupportTicketRequest.QueryTitle, DepartmentId = addSupportTicketRequest.DepartmentId, Query = addSupportTicketRequest.Query, CreatedBy = Utility.UserId }; int result = iSupportTicket.AddSupportTicket(supportTicket); if (result > 0) { bool isSentMail = false; if (addSupportTicketRequest.DepartmentId != null) { var supportTicketEmailHtmlCode = System.IO.File.ReadAllText(string.Format("{0}", HttpContext.Current.Server.MapPath(string.Format("{0}{1}", ConfigurationManager.AppSettings["EmailTemplatePath"], ConfigurationManager.AppSettings["SupportTicketForUserEmailTemplate"])))); var mainTemplateHtmlCode = System.IO.File.ReadAllText(string.Format("{0}", HttpContext.Current.Server.MapPath(string.Format("{0}{1}", ConfigurationManager.AppSettings["EmailTemplatePath"], ConfigurationManager.AppSettings["MainEmailTemplate"])))); mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[SITEURL]", ConfigurationManager.AppSettings["SiteUrl"]); mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[SITENAME]", ConfigurationManager.AppSettings["SiteName"]); mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[PAGECONTENT]", supportTicketEmailHtmlCode); string subject = "Support Ticket | Demystify Fema"; string body = mainTemplateHtmlCode; string displayName = ConfigurationManager.AppSettings["SiteName"]; isSentMail = Utility.SendMail(ConfigurationManager.AppSettings["AdminEmailId"], string.Empty, string.Empty, subject, body, displayName, string.Empty, true); } else { var supportTicketEmailHtmlCode = System.IO.File.ReadAllText(string.Format("{0}", HttpContext.Current.Server.MapPath(string.Format("{0}{1}", ConfigurationManager.AppSettings["EmailTemplatePath"], ConfigurationManager.AppSettings["PostQueryForUserEmailTemplate"])))); var mainTemplateHtmlCode = System.IO.File.ReadAllText(string.Format("{0}", HttpContext.Current.Server.MapPath(string.Format("{0}{1}", ConfigurationManager.AppSettings["EmailTemplatePath"], ConfigurationManager.AppSettings["MainEmailTemplate"])))); mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[SITEURL]", ConfigurationManager.AppSettings["SiteUrl"]); mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[SITENAME]", ConfigurationManager.AppSettings["SiteName"]); mainTemplateHtmlCode = mainTemplateHtmlCode.Replace("[PAGECONTENT]", supportTicketEmailHtmlCode); string subject = "Post Query | Demystify Fema"; string body = mainTemplateHtmlCode; string displayName = ConfigurationManager.AppSettings["SiteName"]; isSentMail = Utility.SendMail(ConfigurationManager.AppSettings["AdminEmailId"], string.Empty, string.Empty, subject, body, displayName, string.Empty, true); } try { var objSupportTicket = new SupportTicket() { SupportTicketId = result, IsMailSentToAdmin = isSentMail, ModifiedBy = Utility.UserId }; iSupportTicket.UpdateSupportTicketMailSent(objSupportTicket); } catch (Exception ex) { Utility.WriteLog("AddSupportTicket", addSupportTicketRequest, "Error while update supportticket mailsent. (SupportTicketUserController)", ex.ToString()); } responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "Post query added successfully."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding post query."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding post query."; Utility.WriteLog("AddSupportTicket", addSupportTicketRequest, "Error while adding supportticket. (SupportTicketUserController)", ex.ToString()); } return(Ok(responses)); }