-
Notifications
You must be signed in to change notification settings - Fork 0
14 encja rezerwacja #19
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
14-encja-rezerwacja
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
82e8e00
git ign
8bf4887
reservation entity with moving to api directory
c40f25a
remove misspelled directory
344fcf2
fixes
2bd8717
merge 6
3d14d1a
change directory tree
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 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
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,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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| using System.ComponentModel.DataAnnotations.Schema; | ||
|
|
||
| namespace web_library.BookReservation.Entity | ||
| { | ||
| using System.ComponentModel.DataAnnotations; | ||
| using web_library.Book.Entity; | ||
|
|
||
| [Table("reservations")] | ||
| public class Reservation | ||
| { | ||
| [Column("id")] | ||
| [Key] | ||
| public int Id { get; set; } | ||
| [Column("reservation_start_date")] | ||
| public DateOnly reservationStartDate { get; } | ||
| [Column("reservation_end_date")] | ||
| public DateOnly reservationEndDate { get; } | ||
| [Column("book_copy_id")] | ||
| public int bookCopyId { get; set; } | ||
| public BookCopy bookCopy { get; set; } = null!; | ||
|
|
||
| public Reservation() | ||
| { | ||
| reservationStartDate = new(); | ||
| reservationEndDate = reservationStartDate.AddMonths(+1); | ||
| } | ||
| public Reservation(BookCopy book) | ||
| { | ||
| bookCopy = book; | ||
| } | ||
| } | ||
| } | ||
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,65 +1,72 @@ | ||
| using Microsoft.EntityFrameworkCore; | ||
| using web_library.User.Entity; | ||
|
|
||
| namespace web_library; | ||
|
|
||
| public class DataContext : DbContext | ||
| namespace web_library | ||
| { | ||
| protected readonly IConfiguration Configuration; | ||
|
|
||
| public DataContext(IConfiguration configuration) | ||
| { | ||
| Configuration = configuration; | ||
| } | ||
|
|
||
| protected override void OnConfiguring(DbContextOptionsBuilder options) | ||
| { | ||
| // connect to postgres with connection string from app settings | ||
| options.UseNpgsql(Configuration.GetConnectionString("WebApiDatabase")); | ||
| } | ||
|
|
||
| protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
| using Api.Book.Entity; | ||
| using Api.Genre.Entity; | ||
| using Api.User.Entity; | ||
| using Api.BookReservation.Entity; | ||
| using web_library.Book.Entity; | ||
| using web_library.BookReservation.Entity; | ||
| using web_library.User.Entity; | ||
|
|
||
| public class DataContext : DbContext | ||
| { | ||
| modelBuilder.Entity<Book.Entity.Book>() | ||
| .HasMany(left => left.Genres) | ||
| .WithMany(right => right.Books) | ||
| .UsingEntity<Dictionary<string, object>>( | ||
| "book_genres", | ||
| j => j.HasOne<Genre.Entity.Genre>().WithMany().HasForeignKey("genre_id"), | ||
| j => j.HasOne<Book.Entity.Book>().WithMany().HasForeignKey("book_id") | ||
| ); | ||
| protected readonly IConfiguration Configuration; | ||
|
|
||
| modelBuilder.Entity<User.Entity.User>(entity => | ||
| public DataContext(IConfiguration configuration) | ||
| { | ||
| entity.ToTable("users"); | ||
| entity.HasIndex(u => u.Email).IsUnique(); | ||
| Configuration = configuration; | ||
| } | ||
|
|
||
| entity.HasOne(u => u.UserBasicInfo) | ||
| .WithOne(ubi => ubi.User) | ||
| .HasForeignKey<UserBasicInfo>(ubi => ubi.UserId) | ||
| .OnDelete(DeleteBehavior.Cascade); | ||
| }); | ||
| protected override void OnConfiguring(DbContextOptionsBuilder options) | ||
| { | ||
| // connect to postgres with connection string from app settings | ||
| options.UseNpgsql(Configuration.GetConnectionString("WebApiDatabase")); | ||
| } | ||
|
|
||
| modelBuilder.Entity<UserBasicInfo>(entity => | ||
| protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
| { | ||
| entity.ToTable("user_basic_info"); | ||
| modelBuilder.Entity<Book>() | ||
| .HasMany(left => left.Genres) | ||
| .WithMany(right => right.Books) | ||
| .UsingEntity<Dictionary<string, object>>( | ||
| "book_genres", | ||
| j => j.HasOne<Genre>().WithMany().HasForeignKey("genre_id"), | ||
| j => j.HasOne<Book>().WithMany().HasForeignKey("book_id") | ||
| ); | ||
|
|
||
| entity.Property(ubi => ubi.UserId).IsRequired(); | ||
| modelBuilder.Entity<User>(entity => | ||
| { | ||
| entity.ToTable("users"); | ||
| entity.HasIndex(u => u.Email).IsUnique(); | ||
|
|
||
| entity.HasIndex(ubi => ubi.UserId).IsUnique(); | ||
| entity.HasOne(u => u.UserBasicInfo) | ||
| .WithOne(ubi => ubi.User) | ||
| .HasForeignKey<UserBasicInfo>(ubi => ubi.UserId) | ||
| .OnDelete(DeleteBehavior.Cascade); | ||
| }); | ||
|
|
||
| }); | ||
| modelBuilder.Entity<UserBasicInfo>(entity => | ||
| { | ||
| entity.ToTable("user_basic_info"); | ||
|
|
||
| base.OnModelCreating(modelBuilder); | ||
| } | ||
| entity.Property(ubi => ubi.UserId).IsRequired(); | ||
|
|
||
| entity.HasIndex(ubi => ubi.UserId).IsUnique(); | ||
|
|
||
| public DbSet<User.Entity.User> Users { get; set; } | ||
| }); | ||
|
|
||
| base.OnModelCreating(modelBuilder); | ||
| } | ||
|
|
||
| public DbSet<Book.Entity.Book> Books { get; set; } | ||
| public DbSet<Book.Entity.BookCopy> BooksCopy { get; set; } | ||
| public DbSet<Genre.Entity.Genre> Genres { get; set; } | ||
| public DbSet<User> Users { get; set; } | ||
|
|
||
|
|
||
| public DbSet<UserBasicInfo> UserBasicInfos { get; set; } | ||
| public DbSet<Book> Books { get; set; } | ||
| public DbSet<BookCopy> BooksCopy { get; set; } | ||
| public DbSet<Genre> Genres { get; set; } | ||
| public DbSet<Reservation> Reservations { get; set; } | ||
| public DbSet<UserBasicInfo> UserBasicInfos { 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,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
Oops, something went wrong.
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.
rezerwacja nie ma end date(zrob serwis ktory na podstawie daty sprawdza czy nie powinno sie jej zdjąć, jak jest wypozyczona to czekaj z wygasnieciem do konca wypozyczenia +3 dni, jak nie to poprostu 3 dni