Skip to content
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

Feat/ApiControllerTest #158

Open
wants to merge 24 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
41e43ed
Merge pull request #146 from green-fox-academy/release-v0.4.1
AlexTeper Jul 31, 2019
81f33c2
feat(ApiControllerTest): init
koger23 Aug 8, 2019
8c6a09a
Merge pull request #154 from green-fox-academy/release-v0.5.0
kriszmagyar Aug 9, 2019
fd45280
fix(Swagger): update comments xml path
kriszmagyar Aug 9, 2019
54323bd
Merge pull request #155 from green-fox-academy/release-v0.5.0
koger23 Aug 9, 2019
183a185
fix(Swagger): link
kriszmagyar Aug 9, 2019
040af48
Merge pull request #156 from green-fox-academy/release-v0.5.0
koger23 Aug 9, 2019
50e98f7
fix(Apicontroller): fix Hotels()
koger23 Aug 9, 2019
025c4b4
feat(ApiControllerTest): add new fact
koger23 Aug 9, 2019
8b2f7c3
Merge branch 'master' of https://github.com/green-fox-academy/ferrila…
koger23 Aug 9, 2019
6f9632f
feat(ApiControllerTest): add new method
koger23 Aug 9, 2019
f84f2cf
fix(ApiController): remove QueryParams from FindHotel()
koger23 Aug 9, 2019
953ea20
feat(ApiController): tests for FindHotel()
koger23 Aug 9, 2019
4ea0256
feat(ApiControllerTest): create tests for FindAllHotelImages()
koger23 Aug 9, 2019
a50c6e4
feat(ApiControllerTest): create tests for Rooms
koger23 Aug 9, 2019
a4c8303
feat(ApiControllerTest): create tests for Reserve()
koger23 Aug 9, 2019
dc7dc7c
feat(ApiControllerTest): create tests for Confirm()
koger23 Aug 9, 2019
1091c84
refactor(ApiControllerTest): fix naming
koger23 Aug 9, 2019
a2751c9
feat(ApiControllerTest): create tests for Delete()
koger23 Aug 9, 2019
4c4a398
feat(ApiControllerTest): create tests for FindAllReservations()
koger23 Aug 9, 2019
d9733ae
refactor(*): refactor code
koger23 Aug 10, 2019
c2a12e4
fix(ApiControllerTest): fix assertions
koger23 Aug 12, 2019
cfc4c5b
fix(Settings.cshtml): add translations
koger23 Aug 12, 2019
f115100
fix(ApiControllerTest): fix adding hotel to context
koger23 Aug 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
485 changes: 485 additions & 0 deletions hotel-booking-app-tests/Controllers/ApiControllerTest.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions hotel-booking-app-tests/HotelBookingAppTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.1" />
Expand Down
8 changes: 7 additions & 1 deletion hotel-booking-app/Configs/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.OpenApi.Models;
using Newtonsoft.Json.Serialization;
using System;
using System.IO;
using System.Reflection;
using System.Text;

Expand Down Expand Up @@ -106,7 +107,12 @@ public static IServiceCollection AddSwaggerDoc(this IServiceCollection services)
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "API Endpoints", Version = "v1" });
c.EnableAnnotations();
c.IncludeXmlComments(string.Format(@"{0}\HotelBookingApp.xml", AppDomain.CurrentDomain.BaseDirectory));

var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML";
var commentsFile = Path.Combine(baseDirectory, commentsFileName);

c.IncludeXmlComments(commentsFile);
});
return services;
}
Expand Down
20 changes: 8 additions & 12 deletions hotel-booking-app/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
Expand Down Expand Up @@ -111,32 +109,30 @@ public async Task<IActionResult> Register([FromBody] SignupRequest request)
}

/// <summary>
/// Get a list of hotels, but max. 10 at once.
/// Get a list of hotels, but max. 10 at once. Although it is customizeable with QueryParams properties
/// Current page can be changed with "currentPage" parameter.
/// Hotels can be filtered with given "city" parameter.
/// </summary>
/// <remarks>
/// Sample request:
///
/// GET /api/hotels
/// {
/// }
///
/// </remarks>
/// <param name="city"></param>
/// <param name="currentPage"></param>
/// <param name="queryParams"></param>
/// <returns>Returns a paginated list of hotels with required page. Max. 10 hotels/page.</returns>
/// <response code="200">Returns a paginated list of hotels.</response>
/// <response code="400">Returns a string with error message.</response>
[ProducesResponseType(typeof(PaginatedList<Hotel>), 200)]
[ProducesResponseType(typeof(string), 400)]
[AllowAnonymous]
[HttpGet("hotels")]
public async Task<IActionResult> Hotels(string city, int currentPage = 1)
public async Task<IActionResult> Hotels(QueryParams queryParams)
{
var paginatedHotels = await hotelService.FindWithQuery(new QueryParams
{
CurrentPage = currentPage,
Search = city
});
var paginatedHotels = await hotelService.FindWithQuery(queryParams);

if (paginatedHotels.TotalPages < paginatedHotels.CurrentPage)
{
return BadRequest(string.Format("Error: the current page is greater than the number of pages. Max. page: {0}", paginatedHotels.TotalPages));
Expand Down Expand Up @@ -165,7 +161,7 @@ public async Task<IActionResult> FindHotel(int hotelId)
{
try
{
var hotel = await hotelService.FindByIdAsync(hotelId, new QueryParams());
var hotel = await hotelService.FindByIdAsync(hotelId);
return Ok(hotel);
}
catch (ItemNotFoundException e)
Expand Down
1 change: 1 addition & 0 deletions hotel-booking-app/HotelBookingApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<UserSecretsId>f7f05164-0f39-4cd5-be22-b007008ea157</UserSecretsId>
<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
6 changes: 6 additions & 0 deletions hotel-booking-app/Resources/Views/Settings/Settings.hu.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="API endpoints for mobile app development:" xml:space="preserve">
<value>API endpoint-ok mobilapplikáció fejlesztéshez:</value>
</data>
<data name="Change password" xml:space="preserve">
<value>Jelszó módosítás</value>
</data>
<data name="Developer" xml:space="preserve">
<value>Fejlesztő</value>
</data>
<data name="Language" xml:space="preserve">
<value>Nyelv</value>
</data>
Expand Down
6 changes: 4 additions & 2 deletions hotel-booking-app/Services/AccountService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ public async Task<List<string>> SignInAsync(LoginRequest request)
public async Task<LoginResponseDTO> SignInApiAsync(LoginRequest request)
{
var errors = await SignInAsync(request);
var response = new LoginResponseDTO();
response.errors = errors;
var response = new LoginResponseDTO
{
errors = errors
};

if (errors.Count == 0)
{
Expand Down
4 changes: 2 additions & 2 deletions hotel-booking-app/Views/Settings/Settings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@

<a class="btn btn-danger" asp-controller="Settings" asp-action="Password" role="button">@Localizer["Change password"]</a>
<hr />
<h4>@Localizer["Developer Settings"]</h4>
API endpoints for mobile app development: <a class="btn btn-primary" href="~/swagger/ui/index.html" role="button">API</a>
<h4>@Localizer["Developer"]</h4>
@Localizer["API endpoints for mobile app development:"] <a class="btn btn-primary" href="~/swagger/index.html" role="button">API</a>
4 changes: 0 additions & 4 deletions hotel-booking-app/wwwroot/swagger/ui/custom.css

This file was deleted.

Binary file removed hotel-booking-app/wwwroot/swagger/ui/favicon-16x16.png
Binary file not shown.
Binary file removed hotel-booking-app/wwwroot/swagger/ui/favicon-32x32.png
Binary file not shown.
60 changes: 0 additions & 60 deletions hotel-booking-app/wwwroot/swagger/ui/index.html

This file was deleted.

67 changes: 0 additions & 67 deletions hotel-booking-app/wwwroot/swagger/ui/oauth2-redirect.html

This file was deleted.

134 changes: 0 additions & 134 deletions hotel-booking-app/wwwroot/swagger/ui/swagger-ui-bundle.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions hotel-booking-app/wwwroot/swagger/ui/swagger-ui.css

This file was deleted.

1 change: 0 additions & 1 deletion hotel-booking-app/wwwroot/swagger/ui/swagger-ui.css.map

This file was deleted.

9 changes: 0 additions & 9 deletions hotel-booking-app/wwwroot/swagger/ui/swagger-ui.js

This file was deleted.

1 change: 0 additions & 1 deletion hotel-booking-app/wwwroot/swagger/ui/swagger-ui.js.map

This file was deleted.