public JsonResult GetProgramTemplateData(ProgramtemplateBO Model) { Model.ProgramName = Model.ProgramName.TrimEnd(); return(Json(new { redirectUrl = Url.Action("ModifyProgramTemplate", "Program", new { Model.TemplateID, Model.ProgramName, Model.IsBaseTemplate, Model.IsModify, Model.TemplateTable, Model.ProgramID, Model.TemplatePath }), isRedirect = true })); }
public JsonResult GetFormHtmlById(int Id) { if (Id == 0) { return(Json(new { html = "", IsActive = 0, Isactivated = 0 }, JsonRequestBehavior.AllowGet)); } string PathName = string.Empty; ProgramtemplateBO data = new ProgramtemplateBO(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(WebApiKey); //HTTP GET var responseTask = client.GetAsync("/api/PatientMain/GetProgramTemplateByID?ID=" + Id); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <ProgramtemplateBO>(); readTask.Wait(); data = readTask.Result; } else //web api sent error response { //log response status here.. } } PathName = data.TemplatePath; if (PathName != "" && PathName != null) { var gethtml = System.IO.File.ReadAllText(Server.MapPath("~/App_Data/Templates/ProgramsTemplate/" + PathName)); var jsonResult = new { html = gethtml, IsActive = data.IsActive, Isactivated = data.Isactivated }; return(Json(jsonResult, JsonRequestBehavior.AllowGet)); } //var gethtml= System.IO.File.ReadAllText(Server.MapPath("~/App_Data/data.html")); return(Json(new { html = "", IsActive = 0, Isactivated = 0 }, JsonRequestBehavior.AllowGet)); }
public ActionResult ModifyProgramTemplate(ProgramtemplateBO data) { ViewBag.TemplateId = data.TemplateID; ViewBag.IsModify = data.IsModify; ViewBag.TemplateName = data.ProgramName; ViewBag.IsBaseTemplate = data.IsBaseTemplate; ViewBag.IsBaseTemplate = data.IsBaseTemplate; ViewBag.TemplateTable = data.TemplateTable; ViewBag.ProgramID = data.ProgramID; ViewBag.TemplatePath = data.TemplatePath; return(View()); }
public JsonResult SaveFormTemplate(ProgramtemplateBO Model, string htmlTemplate = null, string TemplatePath = null) { string TemplateName = ""; string dataFile = ""; string path = ""; if (Model.IsBaseTemplate) { Model.ProgramName = "BaseProgramTemplate"; TemplateName = Guid.NewGuid().ToString() + ".html"; path = "~/App_Data/Templates/ProgramsTemplate/BaseTemplate"; if (!Directory.Exists(path)) { Directory.CreateDirectory(Server.MapPath(path)); } dataFile = Server.MapPath(path + "/" + TemplateName); System.IO.File.WriteAllText(@dataFile, htmlTemplate); Model.TemplatePath = "BaseTemplate/" + TemplateName; Model.TemplateTable = "tbl_" + Model.ProgramName; Model.IsBaseTemplate = true; } else { if (htmlTemplate != null) { path = "~/App_Data/Templates/ProgramsTemplate/" + Model.ProgramID; if (!Directory.Exists(path)) { Directory.CreateDirectory(Server.MapPath(path)); } TemplateName = Guid.NewGuid().ToString() + ".html"; dataFile = Server.MapPath(path + "/" + TemplateName); System.IO.File.WriteAllText(@dataFile, htmlTemplate); Model.TemplatePath = Model.ProgramID + "/" + TemplateName; } if (TemplatePath != null && htmlTemplate == null) { Model.TemplatePath = TemplatePath; } if (!Model.IsModify) { Model.TemplateTable = "tbl_" + Model.ProgramName.Replace(" ", "") + "_Program"; } } using (var client = new HttpClient()) { client.BaseAddress = new Uri(WebApiKey); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var responseTask = client.PostAsJsonAsync("api/PatientMain/saveprogramtemplate", Model); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var data = result.Content.ReadAsStringAsync().Result; if (data == "0") { return(Json("0")); } else { return(Json(new { id = data, })); } } } return(Json("")); }