public async System.Threading.Tasks.Task Add(Project project)
 {
     if (project.CreationDate == null)
     {
         throw new ArgumentOutOfRangeException("Project creation date must be set!");
     }
     _context.Project.Add(project);
     await _context.SaveChangesAsync();
 }
 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();
 }
Exemple #3
0
        public async Task <File> Delete(int id)
        {
            var removeFile = await _context.File.FindAsync(id);

            if (removeFile == null)
            {
                return(null);
            }

            var RemoveFilePhysical = await _context.File.SingleOrDefaultAsync(m => m.Id == id);

            _context.File.Remove(removeFile);
            await _context.SaveChangesAsync();

            System.IO.File.Delete(RemoveFilePhysical.FilePath);

            return(removeFile);
        }