示例#1
0
        public async Task <IActionResult> ImportFromFile(IFormFile file, NotePackageDetailDto dto)
        {
            var notes       = _converter.Convert(file);
            var nodePackage = new NotePackage()
            {
                Title    = dto.Title,
                Category = new Category()
                {
                    Id = dto.CategoryId
                },
                Notes = notes.ToList()
            };
            await _userNotesService.AddNotePackage(GetIdentityName(), nodePackage);

            return(StatusCode(201));
        }
示例#2
0
        public async Task AddNotePackage(string userName, NotePackage package)
        {
            var user = await _uow.UserRepository.GetByName(userName);

            if (user is null)
            {
                throw new ArgumentException($"User with name {userName} don't exist '");
            }

            var categoryId = package.Category.Id;

            if (!await _uow.NotePackageRepository.IsCategoryExist(categoryId))
            {
                throw new ArgumentException($"Category with {categoryId} don't exist'");
            }

            package.Owner = user;
            await _uow.NotePackageRepository.Add(package);

            await _uow.Commit();
        }
示例#3
0
 public Task Add(NotePackage package)
 {
     return(_context.NotePackages.AddAsync(package));
 }
示例#4
0
 public PdfNotesDto Generate(NotePackage notePackage, int limitOfNotes = 30)
 {
     throw  new NotImplementedException();
 }