public Object GetName4([FromHeader] ClaimDTO claimDto) { String name = ""; if (claimDto != null) { name = claimDto.FullName; } return(new { data = name }); }
public Object GetPersons([FromHeader] ClaimDTO claimDto) { try { var persons = DummyDAL.GetPersons(claimDto.UserID); return(new { success = true, data = persons }); } catch (Exception ex) { return(new { success = false }); } }
public void UploadFile(List <IFormFile> UploadedImage, [FromHeader] ClaimDTO claimDto) { //var files = HttpContext.Request.Form.Files; var age = HttpContext.Request.Form["Age"].FirstOrDefault(); foreach (var file in UploadedImage) { FileDTO fileDTO = new FileDTO(); fileDTO.FileActualName = file.FileName; fileDTO.FileExt = Path.GetExtension(file.FileName); fileDTO.ContentType = file.ContentType; //Generate a unique name using Guid //fileDTO.FileUniqueName = Guid.NewGuid().ToString(); //OR fileDTO.FileUniqueName = Path.GetRandomFileName(); //Any data we want to get from claim fileDTO.UploadedByID = claimDto.UserID; //Get physical path of our folder where we want to save images //var rootPath = HttpContext.Current.Server.MapPath("~/UploadedFiles"); // This doesn't work now //How to get root path? // Hard code root path in configuration? //Use IWebHostEnvironment var p1 = _env.ContentRootPath; var p2 = _env.WebRootPath; var fileSavePath = System.IO.Path.Combine(p1, "UploadFiles", fileDTO.FileUniqueName + fileDTO.FileExt); // Save the uploaded file to "UploadedFiles" folder using (var stream = System.IO.File.Create(fileSavePath)) { file.CopyTo(stream); } //Save File Meta data in Database DummyDAL.SaveFileInDB(fileDTO); } }