-
Notifications
You must be signed in to change notification settings - Fork 0
6 endpoint do dodawania gatunku #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RaidenPL
wants to merge
12
commits into
master
Choose a base branch
from
6-endpoint-do-dodawania-gatunku
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
927ce48
add controller for genre
e795260
merge "master"
5b5e7c4
add endpoint for gatunkes
06b2b64
essa
880ef25
Merge branch 'master' into 6-endpoint-do-dodawania-gatunku
6a2fc2f
v1 fix
c40f25a
remove misspelled directory
344fcf2
fixes
6cc7c24
removed unused endpoints
dd09844
t1
3f91dcb
fix migration
3b97700
fixes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,42 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using web_library.Book.DataProvider; | ||
| using web_library.Book.DataProvider; | ||
|
|
||
| namespace web_library.Book.Repository | ||
| namespace web_library.Book.Repository; | ||
| using SharedExceptions; | ||
| using Entity; | ||
|
|
||
| public class BookRepository : IBookRepository | ||
| { | ||
| public class BookRepository : IBookRepository | ||
| private readonly DataContext _context; | ||
| public BookRepository(DataContext context) | ||
| { | ||
| private readonly DataContext _context; | ||
| public BookRepository(DataContext context) | ||
| { | ||
| _context = context; | ||
| } | ||
| _context = context; | ||
| } | ||
|
|
||
| public void Add(Entity.Book entity) | ||
| { | ||
| _context.Books.Add(entity); | ||
| _context.SaveChanges(); | ||
| } | ||
| public void Add(Book entity) | ||
| { | ||
| _context.Books.Add(entity); | ||
| _context.SaveChanges(); | ||
| } | ||
|
|
||
| public IEnumerable<Entity.Book> GetAll() | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| public IEnumerable<Book> GetAll() | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Entity.Book GetByIdOrThrow(int id) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| public Book GetByIdOrThrow(int id) | ||
| { | ||
| Book? book = _context.Books.Find(id) ?? throw new NotFoundException("Book "+id+" not found in reposiotry"); | ||
| return book; | ||
| } | ||
|
|
||
| public void Remove(Entity.Book entity) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| public void Remove(Book entity) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public void Update(Entity.Book entity) | ||
| { | ||
| _context.Books.Update(entity); | ||
| _context.SaveChanges(); | ||
| } | ||
| public void Update(Book entity) | ||
| { | ||
| _context.Books.Update(entity); | ||
| _context.SaveChanges(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace web_library.Book.Request | ||
| { | ||
| public class AssigneGenreToBookRequest | ||
| { | ||
|
|
||
| public ICollection<int> genres_ids { get; set; } | ||
| [JsonIgnore] | ||
| public int book_id { get; set; } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| using Microsoft.AspNetCore.Mvc; | ||
|
|
||
| namespace web_library.Genre.Controller | ||
| { | ||
| using web_library.Genre.Request; | ||
| using web_library.Genre.Service; | ||
|
|
||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
| public class GenresController : ControllerBase | ||
| { | ||
| private readonly IGenreService _genreService; | ||
|
|
||
| public GenresController(IGenreService genreService) | ||
| { | ||
| _genreService = genreService; | ||
| } | ||
|
|
||
| [HttpPost] | ||
| public ActionResult Post([FromBody] CreateGenreRequest request) | ||
| { | ||
| try | ||
| { | ||
| _genreService.createGenre(request); | ||
| return Ok(); | ||
| } | ||
| catch | ||
| (Exception) | ||
| { | ||
| return BadRequest(); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| namespace web_library.Genre.Repository; | ||
|
|
||
| using Entity; | ||
| using SharedExceptions; | ||
|
|
||
| public class GenreRepository : IGenreRepository | ||
| { | ||
| private readonly DataContext _context; | ||
| public GenreRepository(DataContext context) | ||
| { | ||
| _context = context; | ||
| } | ||
|
|
||
| public void Add(Genre entity) | ||
| { | ||
| _context.Genres.Add(entity); | ||
| _context.SaveChanges(); | ||
| } | ||
|
|
||
| public IEnumerable<Genre> GetAll() | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Genre GetByIdOrThrow(int id) | ||
| { | ||
| Genre? genre = _context.Genres.Find(id) ?? throw new NotFoundException("Genre "+id+" not found in repository"); | ||
| return genre; | ||
| } | ||
|
|
||
| public void Remove(Genre entity) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace web_library.Genre.Repository | ||
| { | ||
| using Entity; | ||
| public interface IGenreRepository : IGenericRepository<Genre> | ||
| { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace web_library.Genre.Request | ||
| { | ||
| public class CreateGenreRequest | ||
| { | ||
| public string Name { get; set; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using Newtonsoft.Json; | ||
| using web_library.Genre.Repository; | ||
| using web_library.Genre.Request; | ||
|
|
||
| namespace web_library.Genre.Service | ||
| { | ||
| using Entity; | ||
| using Newtonsoft.Json; | ||
|
|
||
| public class GenreService : IGenreService | ||
| { | ||
| private readonly IGenreRepository _genreRepository; | ||
|
|
||
| public GenreService(IGenreRepository genreRepository) | ||
| { | ||
| _genreRepository = genreRepository; | ||
| } | ||
|
|
||
| public void createGenre(CreateGenreRequest request) | ||
| { | ||
| var jsonString = JsonConvert.SerializeObject(request); | ||
|
|
||
| Genre? genre = JsonConvert.DeserializeObject<Genre>(jsonString) ?? throw new JsonException(); | ||
|
|
||
| _genreRepository.Add(genre); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using web_library.Genre.Request; | ||
|
|
||
| namespace web_library.Genre.Service | ||
| { | ||
| public interface IGenreService | ||
| { | ||
| void createGenre(CreateGenreRequest request); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Po co to ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request do kontrolera książki który do isniejącej książki dodaje gatunki