Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions AJS.Services/AJS.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
</PropertyGroup>

<ItemGroup>
<Folder Include="Models\" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
<ProjectReference Include="..\AJS.Data\AJS.Data.csproj" />
</ItemGroup>

</Project>
20 changes: 18 additions & 2 deletions AJS.Services/Implementations/AdsApiService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
using AJS.Services.Interfaces;
using AJS.Data;
using AJS.Services.Interfaces;
using AJS.Services.Models;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AJS.Services.Implementations
{
Expand All @@ -7,9 +13,19 @@ namespace AJS.Services.Implementations
/// </summary>
public class AdsApiService : IAdsApiService
{
public AdsApiService()
private readonly AJSDbContext db;

public AdsApiService(AJSDbContext db)
{
this.db = db;
}

public async Task<List<AdApiServiceModel>> GetAllAds()
{
return await db.Ad.Select(a => new AdApiServiceModel
{
// TODO: Implement me
}).ToListAsync();
}
}
}
7 changes: 6 additions & 1 deletion AJS.Services/Interfaces/IAdsApiService.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
namespace AJS.Services.Interfaces
using AJS.Services.Models;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace AJS.Services.Interfaces
{
/// <summary>
/// Ads API Service Interface
/// </summary>

public interface IAdsApiService
{
Task<List<AdApiServiceModel>> GetAllAds()
}
}
15 changes: 15 additions & 0 deletions AJS.Services/Models/AdApiServiceModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace AJS.Services.Models
{
public class AdApiServiceModel
{
public string Name { get; set; }

public string Id { get; set; }

// TODO:
}
}
34 changes: 18 additions & 16 deletions AJS.Web/Areas/Api/AdsController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using AJS.Services.Interfaces;
using AJS.Web.Areas.Api.Models;
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;

namespace AJS.Web.Areas.Api
Expand All @@ -13,43 +16,42 @@ namespace AJS.Web.Areas.Api
public class AdsController : ControllerBase
{
private readonly IAdsApiService adsApiService;
private readonly IMapper mapper;

public AdsController(IAdsApiService adsApiService)
public AdsController(IAdsApiService adsApiService, IMapper mapper)
{
this.adsApiService = adsApiService;
this.mapper = mapper;
}

[HttpGet]
[Route("Get")]
[HttpGet("Get")]
public async Task<IActionResult> Get()
{
return new JsonResult("");
var ads = await adsApiService.GetAllAds();
var result = mapper.Map<AdApiModel>(ads);
return new JsonResult(result);
}

[HttpGet]
[Route("GetById")]
public async Task<IActionResult> GetById()
[HttpGet("GetById/{id}")]
public async Task<IActionResult> GetById(string id)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByCategory")]
public async Task<IActionResult> GetByCategory()
[HttpGet("GetByCategory/{categoryName}")]
public async Task<IActionResult> GetByCategory(string categoryName)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByDate")]
public async Task<IActionResult> GetByDate()
[HttpGet("GetByDate/{publicationDate:datetime}")]
public async Task<IActionResult> GetByDate(DateTime publicationDate)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByLastDateSync")]
public async Task<IActionResult> GetByLastDateSync()
[HttpGet("GetByLastDateSync/{lastSyncDate:datetime}")]
public async Task<IActionResult> GetByLastDateSync(DateTime lastSyncDate)
{
return new JsonResult("");
}
Expand Down
24 changes: 10 additions & 14 deletions AJS.Web/Areas/Api/JobsController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AJS.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;

namespace AJS.Web.Areas.Api
Expand All @@ -19,37 +20,32 @@ public JobsController(IJobsApiService jobsApiService)
this.jobsApiService = jobsApiService;
}

[HttpGet]
[Route("Get")]
[HttpGet("Get")]
public async Task<IActionResult> Get()
{
return new JsonResult("");
}

[HttpGet]
[Route("GetById")]
public async Task<IActionResult> GetById()
[HttpGet("GetById/{id}")]
public async Task<IActionResult> GetById(string id)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByCategory")]
public async Task<IActionResult> GetByCategory()
[HttpGet("GetByCategory/{categoryName}")]
public async Task<IActionResult> GetByCategory(string categoryName)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByDate")]
public async Task<IActionResult> GetByDate()
[HttpGet("GetByDate/{publicationDate:datetime}")]
public async Task<IActionResult> GetByDate(DateTime publicationDate)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByLastDateSync")]
public async Task<IActionResult> GetByLastDateSync()
[HttpGet("GetByLastDateSync/{lastSyncDate:datetime}")]
public async Task<IActionResult> GetByLastDateSync(DateTime lastSyncDate)
{
return new JsonResult("");
}
Expand Down
11 changes: 11 additions & 0 deletions AJS.Web/Areas/Api/Models/AdApiModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AJS.Web.Areas.Api.Models
{
public class AdApiModel
{
}
}
26 changes: 11 additions & 15 deletions AJS.Web/Areas/Api/NewsController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using AJS.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -19,37 +20,32 @@ public NewsController(INewsApiService newsApiService)
this.newsApiService = newsApiService;
}

[HttpGet]
[Route("Get")]
[HttpGet("Get")]
public async Task<IActionResult> Get()
{
return new JsonResult("");
}

[HttpGet]
[Route("GetById")]
public async Task<IActionResult> GetById()
[HttpGet("GetById/{id}")]
public async Task<IActionResult> GetById(string id)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByCategory")]
public async Task<IActionResult> GetByCategory()
[HttpGet("GetByCategory/{categoryName}")]
public async Task<IActionResult> GetByCategory(string categoryName)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByDate")]
public async Task<IActionResult> GetByDate()
[HttpGet("GetByDate/{publicationDate:datetime}")]
public async Task<IActionResult> GetByDate(DateTime publicationDate)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByLastDateSync")]
public async Task<IActionResult> GetByLastDateSync()
[HttpGet("GetByLastDateSync/{lastSyncDate:datetime}")]
public async Task<IActionResult> GetByLastDateSync(DateTime lastSyncDate)
{
return new JsonResult("");
}
Expand Down
24 changes: 10 additions & 14 deletions AJS.Web/Areas/Api/ServicesController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AJS.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;

namespace AJS.Web.Areas.Api
Expand All @@ -19,37 +20,32 @@ public ServicesController(IServicesApiService servicesApiService)
this.servicesApiService = servicesApiService;
}

[HttpGet]
[Route("Get")]
[HttpGet("Get")]
public async Task<IActionResult> Get()
{
return new JsonResult("");
}

[HttpGet]
[Route("GetById")]
public async Task<IActionResult> GetById()
[HttpGet("GetById/{id}")]
public async Task<IActionResult> GetById(string id)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByCategory")]
public async Task<IActionResult> GetByCategory()
[HttpGet("GetByCategory/{categoryName}")]
public async Task<IActionResult> GetByCategory(string categoryName)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByDate")]
public async Task<IActionResult> GetByDate()
[HttpGet("GetByDate/{publicationDate:datetime}")]
public async Task<IActionResult> GetByDate(DateTime publicationDate)
{
return new JsonResult("");
}

[HttpGet]
[Route("GetByLastDateSync")]
public async Task<IActionResult> GetByLastDateSync()
[HttpGet("GetByLastDateSync/{lastSyncDate:datetime}")]
public async Task<IActionResult> GetByLastDateSync(DateTime lastSyncDate)
{
return new JsonResult("");
}
Expand Down