public IActionResult Index() { List <DocumentsAM> lstDocs = docBO.Get(); DocVM model = new DocVM { ListDocs = lstDocs }; return(View(model)); }
public ActionResult List(int menuId) { DocVM vm = new DocVM(); vm.HelpMenus = db.HelpMenus; vm.HelpMenu = db.HelpMenus.Single(p => p.MenuId == menuId); vm.HelpDocs = db.HelpDocs.Where(p => p.MenuId == menuId && p.IsVisible); return(View(vm)); }
public async System.Threading.Tasks.Task <IActionResult> LoadDocsAsync(DocVM model) { try { if (ModelState.IsValid) { var apiEndpoint = Configuration["ApiEndpoint"]; var apiClient = new HttpClient(); IFormFile attaCC = Request.Form.Files.Where(x => x.Name == "UploadedFile").ToList()[0]; System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo("wwwroot\\pdf"); var nameFolder = "tempFilesMVM"; var folderPath = Path.Combine(directory.FullName, nameFolder); var filePath = Path.Combine(folderPath, attaCC.FileName); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) { attaCC.CopyTo(stream); stream.Close(); } var doc = UploadFile(attaCC, filePath, model.IdDocumentType); HttpContent content = new StringContent(JsonConvert.SerializeObject(doc), Encoding.UTF8, "application/json"); var response = await apiClient.PostAsync(apiEndpoint + "/api/Docs/CreateDoc", content); if (response.IsSuccessStatusCode) { CreateModal("exito", "Terminado", "Se ha registrado el documento satisfactoriamente.", "Terminar", null, "Redirect('Index')", null); } return(RedirectToAction("Index")); } } catch (Exception ex) { logger.LogInformation(ex.Message); CreateModal("error", "Error", "Error al cargar los documentos.", "Continuar", null, "Redirect('/Providers/Documents/Index')", null); return(View(model)); } return(View(model)); }
public async System.Threading.Tasks.Task <IActionResult> IndexAsync() { DocVM model = new DocVM(); var apiEndpoint = Configuration["ApiEndpoint"]; var apiClient = new HttpClient(); string userId = HttpContext.Session.GetString("IdUsers"); var response = apiClient.GetAsync(apiEndpoint + "/api/Docs/GetDocs/" + userId).Result; if (response.IsSuccessStatusCode) { var strJson = await response.Content.ReadAsStringAsync(); var deserialize = JsonConvert.DeserializeObject <List <DocumentsAM> >(strJson); // model.PersonServiceList = (List<PersonServicesAM>)deserialize; model.ListDocs = deserialize; } return(View(model)); }