Skip to content

Instantly share code, notes, and snippets.

View msciborski's full-sized avatar

Michał Ściborski msciborski

View GitHub Profile
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) ;
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;
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));
}
}
{
"totalItems": 165,
"pageNumber": 1,
"pageSize": 10,
"totalPages": 17,
"hasPreviousPage": false,
"hasNextPage": true,
"nextPageNumber": 2,
"previousPageNumber": 1,
"items": [
Install-Package FluentValidation.AspNetCore
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.AddFluentValidation();
}
public class BookDto
{
public string Title { get; set; }
public string Author { get; set; }
public DateTime? PublishingDate { get; set; }
public int? PagesCount { get; set; }
}
public class UserRegisterDto
{
public string UserName { get; set; }
public string Password { get; set; }
public string Email { get; set; }
public string FirstName { get; set; }
}
public class UserRegisterDto
{
public string UserName { get; set; }
public string Password { get; set; }
public string Email { get; set; }
public string FirstName { get; set; }
}
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.AddFluentValidation(o => o.RegisterValidatorsFromAssemblyContaining<Startup>());
}