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)); }
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(); }
public Task Add(NotePackage package) { return(_context.NotePackages.AddAsync(package)); }
public PdfNotesDto Generate(NotePackage notePackage, int limitOfNotes = 30) { throw new NotImplementedException(); }