Esempio n. 1
0
        public async Task <ActionResult <ProjectDto> > Get([Required] int id)
        {
            var proj = await _projectDatabase.FindOrDefault(id);

            if (proj == null)
            {
                return(NotFound());
            }
            else
            {
                return(ProjectDto.FromProject(proj));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(RedirectToPage("/Index"));
            }

            Project = await _projectContext.FindOrDefault(id.Value);

            if (Project == null)
            {
                return(RedirectToPage("/Index"));
            }

            return(Page());
        }
Esempio n. 3
0
        public async Task <ZwinnyCRUD.Common.Models.File> Upload(string FileName, long Length, Stream Content, int id)
        {
            var Project = await _projectContext.FindOrDefault(id);

            var dirPath  = Path.Combine(_targetFilePath, Convert.ToString(Project.Id));
            var filePath = Path.Combine(dirPath, FileName);

            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            if (System.IO.File.Exists(filePath))
            {
                return(null);
            }

            var myFile = new Common.Models.File
            {
                FilePath    = filePath,
                Name        = FileName,
                SizeinBytes = Length,
                Uploaded    = DateTimeOffset.UtcNow,
                ProjectId   = Project.Id
            };

            using (var fileStream = System.IO.File.Create(filePath))
            {
                await Content.CopyToAsync(fileStream);
            }

            return(myFile);
        }
 public async System.Threading.Tasks.Task Add(Task task)
 {
     if (task.CreationDate == null)
     {
         throw new ArgumentOutOfRangeException("Task creation date must be set!");
     }
     if (_projectContext.FindOrDefault(task.ProjectId) == null)
     {
         throw new ArgumentException("Task's parent project doesn't exists!");
     }
     _context.Task.Add(task);
     await _context.SaveChangesAsync();
 }
Esempio n. 5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Project = await _context.FindOrDefault(id.Value);

            if (Project == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Esempio n. 6
0
        public async Task <ActionResult> UploadFile([FromForm] IFormFile file, int id)
        {
            var Project = await _projectDatabase.FindOrDefault(id);

            if (Project == null)
            {
                return(NotFound("Project with this id doesn't exist!"));
            }
            var fileToUpload = await _uploadService.Upload(file.FileName, file.Length, file.OpenReadStream(), id);

            if (fileToUpload == null)
            {
                return(Conflict("There is already file with that name in this project"));
            }
            await _fileDatabase.Add(fileToUpload);

            return(NoContent());
        }
Esempio n. 7
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            RemoveFile = await _fileContext.SingleOrDefaultAsync(id.Value);

            Project = await _projectContext.FindOrDefault(RemoveFile.ProjectId);

            if (RemoveFile == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Esempio n. 8
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Project = await _projectContext.FindOrDefault(id.Value);

            if (Project == null)
            {
                return(NotFound());
            }

            Project.Tasks = _taskContext.FindAll(e => e.ProjectId == id).ToList();
            File          = await _fileContext.FindProjectFile(id.Value);

            DatabaseFiles = _fileContext.FindAll(m => (m.ProjectId.Equals(Project.Id))).ToList();

            return(Page());
        }