public async Task <ActionResult> RenderDetail(string appId, string id, string dataId) { if (!string.IsNullOrEmpty(appId)) { var response = new ResRenderTabular(); var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.DataViews != null) { ViewBag.AppId = appModule.Id.ToString(); ViewBag.AppName = appModule.Name; ViewBag.DataId = dataId; ViewBag.DataParentId = id; ObjectId dataViewId; if (ObjectId.TryParse(id, out dataViewId)) { if (appModule.DataViews.Any(n => n.Id == dataViewId)) { var dataView = appModule.DataViews.FirstOrDefault(n => n.Id == dataViewId); response.DataView = dataView; var docTypeService = new DocumentTypeServices(_appModuleRepository); if (dataView.SubDocumentTypeId.HasValue) { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.SubDocumentTypeId.Value); } else { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.DocumentTypeId); } //var documentName = await docTypeService.FindDocumentTypeName(appId, dataView.DocumentTypeId); //var org = await _organisationRepository.Get(appModule.OrganisationId); //var dataService = new DataService(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString, org.Id.ToString(), documentName); ////var data = await dataService.Get(dataId, ""); //var data = await dataService.Get(dataId); //var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; //response.Data = data.ToJson(jsonWriterSettings); return(View(response)); } } return(View(response)); } return(View(new DataView())); } } return(View()); }
public async Task <ActionResult> RenderLineChart(string appId, string id, string dataId) { if (!string.IsNullOrEmpty(appId)) { var response = new ResRenderTabular(); var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.Forms != null) { ViewBag.AppId = appModule.Id.ToString(); ViewBag.AppName = appModule.Name; ViewBag.DataId = dataId; ObjectId dataViewId; if (ObjectId.TryParse(id, out dataViewId)) { if (appModule.DataViews.Any(n => n.Id == dataViewId)) { var dataView = appModule.DataViews.FirstOrDefault(n => n.Id == dataViewId); response.DataView = dataView; var docTypeService = new DocumentTypeServices(_appModuleRepository); if (dataView.SubDocumentTypeId.HasValue) { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.SubDocumentTypeId.Value); ViewBag.DocumentTypeName = await docTypeService.FindDocumentTypeName(appId, dataView.SubDocumentTypeId.Value); } else { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, dataView.DocumentTypeId); ViewBag.DocumentTypeName = await docTypeService.FindDocumentTypeName(appId, dataView.DocumentTypeId); } return(View(response)); } } return(View(response)); } return(View(new DataView())); } } return(View()); }
public async Task <JsonResult> ListFields(string documentId, string appId) { var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.DocumentTypes == null) { appModule.DocumentTypes = new List <DocumentType>(); } var docService = new DocumentTypeServices(_appModuleRepository); var fields = await docService.FindDocumentTypeFields(appId, ObjectId.Parse(documentId)); var result = new JsonGenericResult { IsSuccess = true, Result = fields }; return(Json(result, JsonRequestBehavior.AllowGet)); } var errorResult = new JsonGenericResult { IsSuccess = true, Result = appModule.DocumentTypes.FirstOrDefault(n => n.Id.ToString().ToLower().Trim() == documentId.ToLower().Trim()).Fields }; return(Json(errorResult, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> RenderForm(string appId, string reqFormId) { if (!string.IsNullOrEmpty(appId)) { var appModule = await _appModuleRepository.Get(appId); if (appModule != null) { if (appModule.Forms != null) { ViewBag.AppId = appModule.Id.ToString(); ObjectId formId; if (ObjectId.TryParse(reqFormId, out formId)) { if (appModule.Forms.Any(n => n.Id == formId)) { var form = appModule.Forms.FirstOrDefault(n => n.Id == formId); var response = new ResRenderForm(); response.Form = form; var docTypeService = new DocumentTypeServices(_appModuleRepository); if (form.SubDocumentTypeId != null && form.SubDocumentTypeId != ObjectId.Empty) { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, form.SubDocumentTypeId.Value); } else { response.DocumentFields = await docTypeService.FindDocumentTypeFields(appId, form.DocumentTypeId); } return(View(response)); } } } return(View(new ResRenderForm())); } } return(View(new List <ModuleForm>())); }