/// <summary> /// Return PartialView Image /// </summary> /// <param name="entityName">entity name</param> /// <param name="id">entity id</param> /// <returns>ActionResult : PartialView Image</returns> public ActionResult _Details(string entityName, int id) { if (id < 1 || string.IsNullOrWhiteSpace(entityName)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DTO.FileDTO image = Services.ServiceUploadFile.GetUploadedFile(GetImagePath(entityName, id)); return(PartialView("_Details", image)); }
/// <summary> /// Saves an file for an entity. /// </summary> /// <param name="vm">ViewModel <see cref="UploadFileVM"/></param> private void FileUpload(UploadFileVM vm) { if (vm != null && vm.UploadFile != null && vm.UploadFile.ContentLength > 0) { byte[] fileData = null; using (var binaryReader = new BinaryReader(vm.UploadFile.InputStream)) { fileData = binaryReader.ReadBytes(vm.UploadFile.ContentLength); } DTO.FileDTO fileDTO = new DTO.FileDTO(); fileDTO.Binary = fileData; fileDTO.ContentType = vm.UploadFile.ContentType; fileDTO.Name = vm.UploadFile.FileName; Services.ServiceUploadFile.UploadImage(GetImagePath(vm.EntityName, vm.EntityId), fileDTO); } }