This file contains 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
Zadanie 1: | |
-------------------------------------------------------------------------- | |
Plik wejściowy zawiera ciąg wierszy, z których każdy składa się z: nazwiska osoby, niepustego ciągu spacji lub tabulacji i listy oddzielonych od siebie średnikiem ; nazw towarów, po których w nawiasie znajduje się ich cena (liczba rzeczywista), bądź znak -, jeśli cena nie jest znana. Spacje są swobodnie rozmieszczone na liście zakupów. | |
Należy usunąć wszystkie spacje na liście zakupów, a po nazwisku umieścić dokładnie jeden dwukropek i trzy spacje. | |
Nazwisko zaczyna sie z wielkiej litery, nazwa towaru jest pisana z małej litery. | |
Na przykład: | |
Iksinski chleb ( - ) ; mleko ( 3.5); ser (8.24) ; |
This file contains 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
public class PagedList<T> | |
{ | |
public int TotalItems { get; } | |
public int PageNumber { get; } | |
public int PageSize { get; } | |
public int TotalPages => (int) Math.Ceiling(TotalItems / (double) PageSize); | |
public bool HasPreviousPage => PageNumber > 1; | |
public bool HasNextPage => PageNumber < TotalPages; | |
public int NextPageNumber => HasNextPage ? PageNumber + 1 : TotalPages; | |
public int PreviousPageNumber => HasPreviousPage ? PageNumber - 1 : 1; |
This file contains 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
public class BookController : Controller | |
{ | |
[HttpGet] | |
public IActionResult GetBook([FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10) | |
{ | |
return Ok(new PagedList<BookDto>(_context.Books, pageNumber, pageSize)); | |
} | |
} |
This file contains 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
{ | |
"totalItems": 165, | |
"pageNumber": 1, | |
"pageSize": 10, | |
"totalPages": 17, | |
"hasPreviousPage": false, | |
"hasNextPage": true, | |
"nextPageNumber": 2, | |
"previousPageNumber": 1, | |
"items": [ |
This file contains 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
Install-Package FluentValidation.AspNetCore |
This file contains 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
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc() | |
.AddFluentValidation(); | |
} |
This file contains 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
public class BookDto | |
{ | |
public string Title { get; set; } | |
public string Author { get; set; } | |
public DateTime? PublishingDate { get; set; } | |
public int? PagesCount { get; set; } | |
} |
This file contains 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
public class UserRegisterDto | |
{ | |
public string UserName { get; set; } | |
public string Password { get; set; } | |
public string Email { get; set; } | |
public string FirstName { get; set; } | |
} |
This file contains 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
public class UserRegisterDto | |
{ | |
public string UserName { get; set; } | |
public string Password { get; set; } | |
public string Email { get; set; } | |
public string FirstName { get; set; } | |
} |
This file contains 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
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc() | |
.AddFluentValidation(o => o.RegisterValidatorsFromAssemblyContaining<Startup>()); | |
} |
OlderNewer