示例#1
0
        public ProjectAboutFileDto UploadFile([FromServices] ProjectMasterService service,
                                              [FromServices] FileStorageServie storageServie,
                                              [FromForm] IFormCollection form,
                                              [FromForm] long id
                                              )
        {
            if (form.Files.Count == 0)
            {
                throw new LogicException("");
            }
            var file   = form.Files.First();
            var entity = service.GetProject(id);

            if (entity == null)
            {
                throw new LogicException("");
            }
            var path    = Path.Combine("project", entity.Code, ProjectFileType.Create.GetHashCode().ToString(), file.FileName);
            var filedto = storageServie.AddFile(file.OpenReadStream(), path);

            var dto = service.AddAboutFile(0, 0, ProjectFileType.Temp, filedto);

            return(dto.ProjectedAs <ProjectAboutFileDto>());
        }
示例#2
0
        public ProjectAboutFileDto UploadFile([FromServices] ProjectMasterService projectService, [FromServices] FileStorageServie storageServie, [FromForm] IFormCollection form)
        {
            if (form.Files.Count == 0)
            {
                throw new LogicException("");
            }
            var file = form.Files.First();

            var path    = Path.Combine("Temp", file.FileName);
            var filedto = storageServie.AddFile(file.OpenReadStream(), path);

            var dto = projectService.AddAboutFile(0, 0, ProjectFileType.Temp, filedto);

            return(dto.ProjectedAs <ProjectAboutFileDto>());
        }