public void Add(IDalAppFile entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            var file = new AppFile()
            {
                Id           = entity.Id,
                Content      = entity.Content,
                DateUploaded = entity.DateUploaded,
                Name         = entity.Name,
                ContentType  = entity.ContentType,
                Size         = entity.Size
            };

            file.User = _context.Set <User>().Find(entity.UserId);

            if (entity.FolderId != null)
            {
                file.Folder = _context.Set <AppFolder>().Find(entity.FolderId);
            }

            _context.Set <AppFile>().Add(file);
        }
        public void UploadFile(IBllFile file, string userName)
        {
            file.DateUploaded = DateTime.Now;
            IDalAppFile dalFile = file.ToDalAppFile();

            dalFile.UserId = _userService.GetUserByName(userName).Id;
            _fileRepository.Add(dalFile);
            _unitOfWork.Commit();
        }
        public void Delete(IDalAppFile entity)
        {
            if (entity != null)
            {
                var file = _context.Set <AppFile>().Find(entity.Id);

                if (file != null)
                {
                    _context.Set <AppFile>().Remove(file);
                }
            }
        }
        public void UpdateFileFolder(IDalAppFile file, IDalAppFolder folder)
        {
            var fileToUpdate = _context.Set <AppFile>().Find(file.Id);

            if (folder == null)
            {
                fileToUpdate.Folder = null;
            }
            else
            {
                fileToUpdate.Folder = _context.Set <AppFolder>().Find(folder.Id);
            }
        }
 public static IBllFile ToBllFile(this IDalAppFile file)
 {
     return(ToBllFileExpression().Compile()(file));
 }