Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Avengers
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Srujitha Vutla
Avengers
Merge requests
!1
lms with ef
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
lms with ef
srujitha
into
master
Overview
0
Commits
4
Pipelines
0
Changes
23
Merged
Srujitha Vutla
requested to merge
srujitha
into
master
8 months ago
Overview
0
Commits
4
Pipelines
0
Changes
23
Expand
****
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
92879dc6
4 commits,
8 months ago
23 files
+
319
−
217
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
23
Search (e.g. *.vue) (Ctrl+P)
Srujitha/LibraryManagementSystem/LibraryManagementSystem.Api/Controllers/BookController.cs
+
28
−
15
Options
using
System.ComponentModel.DataAnnotations
;
using
LibraryManagementSystem.Api.Filters
;
using
LibraryManagementSystem.Db.Entities
;
using
LibraryManagementSystem.Services.DTO
;
using
LibraryManagementSystem.Services.Implementations
;
using
LibraryManagementSystem.Services.Interfaces
;
using
Microsoft.AspNetCore.Http
;
using
LibraryManagementSystem.Utilities
;
using
LibraryManagementSystem.Utilities.Enums
;
using
Microsoft.AspNetCore.Mvc
;
namespace
LibraryManagementSystem.Api.Controllers
@@ -12,11 +13,9 @@ namespace LibraryManagementSystem.Api.Controllers
[
Route
(
"api/[controller]"
)]
public
class
BookController
:
ControllerBase
{
private
readonly
DataContext
_context
;
private
readonly
IBookManager
_bookManager
;
public
BookController
(
DataContext
context
,
IBookManager
bookManager
)
{
_context
=
context
;
_bookManager
=
bookManager
;
}
[
HttpGet
(
"GetAllBooks"
)]
@@ -24,32 +23,46 @@ namespace LibraryManagementSystem.Api.Controllers
{
return
Ok
(
_bookManager
.
GetAllBooks
(
pageNumber
,
pageSize
));
}
[
ServiceFilter
(
typeof
(
BookOrIdExistenceActionFilter
))]
[
HttpGet
(
"GetBookById"
)]
[
HttpGet
(
"BookList"
)]
public
IActionResult
BookList
()
{
return
Ok
(
_bookManager
.
BookList
());
}
[
ServiceFilter
(
typeof
(
IdExistenceActionFilter
))]
[
HttpGet
(
"GetBookById/{id}"
)]
public
IActionResult
GetBookById
(
int
id
)
{
return
Ok
(
_bookManager
.
GetBookById
(
id
));
}
[
HttpPost
(
"AddBook"
)]
public
IActionResult
AddBook
([
From
Body
]
BookDTO
bookDTO
)
public
IActionResult
AddBook
([
From
Form
]
BookDTO
bookDTO
)
{
_bookManager
.
AddBook
(
bookDTO
);
return
Ok
(
"Book Added Successfully"
);
}
[
HttpPatch
(
"UpdateBook"
)]
[
ServiceFilter
(
typeof
(
BookOr
IdExistenceActionFilter
))]
public
IActionResult
UpdateBook
([
FromForm
]
Book
book
)
[
HttpPatch
(
"UpdateBook
/{id}
"
)]
[
ServiceFilter
(
typeof
(
IdExistenceActionFilter
))]
public
IActionResult
UpdateBook
(
int
id
,
[
FromForm
]
Book
DTO
book
DTO
)
{
_bookManager
.
UpdateBook
(
book
);
_bookManager
.
UpdateBook
(
id
,
book
DTO
);
return
Ok
();
}
[
HttpPut
(
"DeleteBook"
)]
[
ServiceFilter
(
typeof
(
BookOr
IdExistenceActionFilter
))]
public
ActionResult
DeleteBook
(
int
id
)
[
HttpPut
(
"DeleteBook
/({id})
"
)]
[
ServiceFilter
(
typeof
(
IdExistenceActionFilter
))]
public
I
ActionResult
DeleteBook
(
int
id
)
{
_bookManager
.
DeleteBook
(
id
);
return
Ok
();
}
[
HttpPost
(
"SearchBook"
)]
public
IActionResult
SearchBook
([
FromForm
]
SearchUtil
searchUtil
,
int
pageNumber
,
int
pageSize
)
{
return
Ok
(
_bookManager
.
SearchBook
(
searchUtil
,
pageNumber
,
pageSize
));
}
[
HttpGet
(
"SortBook"
)]
public
IActionResult
SortBook
([
Required
]
Property
propertyName
,[
Required
]
Boolean
ascending
,
int
pageNumber
,
int
pageSize
)
{
return
Ok
(
_bookManager
.
SortBook
(
propertyName
,
ascending
,
pageNumber
,
pageSize
));
}
}
}
Loading