correct some errors 🐛
continuous-integration/drone/push Build is failing Details

ApiManager
Emre KARTAL 2 years ago
parent 43cf7792e6
commit 91c36e266c

Binary file not shown.

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Versioning; using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.OpenApi.Models;
using Model; using Model;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@ -9,7 +10,11 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers(); builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "My API v1", Version = "v1" });
options.SwaggerDoc("v2", new OpenApiInfo { Title = "My API v2", Version = "v2" });
});
builder.Services.AddApiVersioning(opt => builder.Services.AddApiVersioning(opt =>

@ -21,22 +21,23 @@ namespace Client
public async Task<IEnumerable<ChampionDto>> GetChampion(int index, int count) public async Task<IEnumerable<ChampionDto>> GetChampion(int index, int count)
{ {
var url = $"{UrlApiChampions}?index={index}&count={count}"; var url = $"{UrlApiChampions}?index={index}&count={count}";
return await _httpClient.GetFromJsonAsync<IEnumerable<ChampionDto>>(url); var Response = await _httpClient.GetFromJsonAsync<PageResponse<ChampionDto>>(url);
return Response.Data;
} }
/* public async void Add(ChampionDto champion) /* public async void Add(ChampionDto champion)
{ {
await _httpClient.PostAsJsonAsync<ChampionDto>(ApiChampions, champion); await _httpClient.PostAsJsonAsync<ChampionDto>(ApiChampions, champion);
}*/ }*/
/* public async void Delete(ChampionDto champion) /* public async void Delete(ChampionDto champion)
{ {
await _httpClient.DeleteAsync(champion.Name); await _httpClient.DeleteAsync(champion.Name);
} }
public async void Update(ChampionDto champion) public async void Update(ChampionDto champion)
{ {
await _httpClient.PutAsJsonAsync<ChampionDto>(ApiChampions, champion); await _httpClient.PutAsJsonAsync<ChampionDto>(ApiChampions, champion);
}*/ }*/
} }
} }

@ -34,4 +34,6 @@ if (championToUpdate != null)
Console.WriteLine($"{championToUpdate.Name} updated."); Console.WriteLine($"{championToUpdate.Name} updated.");
} }
*/ */
Console.ReadLine();

@ -1,4 +1,5 @@
using DbManager.Mapper; using DbManager.Mapper;
using Microsoft.EntityFrameworkCore;
using Model; using Model;
namespace DbLib namespace DbLib
@ -40,22 +41,22 @@ namespace DbLib
= (rune, substring) => rune.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase); = (rune, substring) => rune.Name.Contains(substring, StringComparison.InvariantCultureIgnoreCase);
public async Task<IEnumerable<Rune?>> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Rune?>> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
=> parent.DbContext.Runes.GetItemsWithFilterAndOrdering( => parent.DbContext.Runes.Include(r => r.Image).GetItemsWithFilterAndOrdering(
rune => filterByName(rune.ToModel(), substring), rune => filterByName(rune.ToModel(), substring),
index, count, orderingPropertyName, descending).Select(c => c.ToModel()); index, count, orderingPropertyName, descending).Select(c => c.ToModel());
public async Task<IEnumerable<Rune?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Rune?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
=> parent.DbContext.Runes.GetItemsWithFilterAndOrdering( => parent.DbContext.Runes.Include(r => r.Image).GetItemsWithFilterAndOrdering(
r => true, r => true,
index, count, orderingPropertyName, descending).Select(c => c.ToModel()); index, count, orderingPropertyName, descending).Select(c => c.ToModel());
public async Task<IEnumerable<Rune?>> GetItemsByFamily(RuneFamily family, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Rune?>> GetItemsByFamily(RuneFamily family, int index, int count, string? orderingPropertyName = null, bool descending = false)
=> parent.DbContext.Runes.GetItemsWithFilterAndOrdering( => parent.DbContext.Runes.Include(r => r.Image).GetItemsWithFilterAndOrdering(
rune => filterByRuneFamily(rune.ToModel(), family), rune => filterByRuneFamily(rune.ToModel(), family),
index, count, orderingPropertyName, descending).Select(c => c.ToModel()); index, count, orderingPropertyName, descending).Select(c => c.ToModel());
public async Task<IEnumerable<Rune?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Rune?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
=> parent.DbContext.Runes.GetItemsWithFilterAndOrdering( => parent.DbContext.Runes.Include(r => r.Image).GetItemsWithFilterAndOrdering(
rune => filterByNameContains(rune.ToModel(), substring), rune => filterByNameContains(rune.ToModel(), substring),
index, count, orderingPropertyName, descending).Select(c => c.ToModel()); index, count, orderingPropertyName, descending).Select(c => c.ToModel());

@ -6,7 +6,7 @@ namespace DbManager.Mapper
{ {
public static class RuneMapper public static class RuneMapper
{ {
public static Rune ToModel(this RuneEntity rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, "", rune.Description); public static Rune ToModel(this RuneEntity rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description);
public static RuneEntity ToEntity(this Rune rune) public static RuneEntity ToEntity(this Rune rune)
=> new() => new()
{ {

@ -21,7 +21,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{3
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiTests", "Tests\ApiTests\ApiTests.csproj", "{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiTests", "Tests\ApiTests\ApiTests.csproj", "{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{464DAB04-BE65-429D-9A39-3E1BB43C521A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiManager", "Client\ApiManager.csproj", "{464DAB04-BE65-429D-9A39-3E1BB43C521A}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyFlib", "MyFlib\MyFlib.csproj", "{2142AB69-B483-4B0A-96DC-CFA87DEB11A5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyFlib", "MyFlib\MyFlib.csproj", "{2142AB69-B483-4B0A-96DC-CFA87DEB11A5}"
EndProject EndProject

Loading…
Cancel
Save