diff --git a/AJS.Services/AJS.Services.csproj b/AJS.Services/AJS.Services.csproj
index 4fe0679..99eb223 100644
--- a/AJS.Services/AJS.Services.csproj
+++ b/AJS.Services/AJS.Services.csproj
@@ -13,12 +13,12 @@
-
+
+
-
-
+
diff --git a/AJS.Services/Implementations/AdsApiService.cs b/AJS.Services/Implementations/AdsApiService.cs
index 189fc91..e208b8f 100644
--- a/AJS.Services/Implementations/AdsApiService.cs
+++ b/AJS.Services/Implementations/AdsApiService.cs
@@ -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
{
@@ -7,9 +13,19 @@ namespace AJS.Services.Implementations
///
public class AdsApiService : IAdsApiService
{
- public AdsApiService()
+ private readonly AJSDbContext db;
+
+ public AdsApiService(AJSDbContext db)
{
+ this.db = db;
+ }
+ public async Task> GetAllAds()
+ {
+ return await db.Ad.Select(a => new AdApiServiceModel
+ {
+ // TODO: Implement me
+ }).ToListAsync();
}
}
}
diff --git a/AJS.Services/Interfaces/IAdsApiService.cs b/AJS.Services/Interfaces/IAdsApiService.cs
index a011e09..ea8fbca 100644
--- a/AJS.Services/Interfaces/IAdsApiService.cs
+++ b/AJS.Services/Interfaces/IAdsApiService.cs
@@ -1,4 +1,8 @@
-namespace AJS.Services.Interfaces
+using AJS.Services.Models;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace AJS.Services.Interfaces
{
///
/// Ads API Service Interface
@@ -6,5 +10,6 @@
public interface IAdsApiService
{
+ Task> GetAllAds()
}
}
diff --git a/AJS.Services/Models/AdApiServiceModel.cs b/AJS.Services/Models/AdApiServiceModel.cs
new file mode 100644
index 0000000..e385a78
--- /dev/null
+++ b/AJS.Services/Models/AdApiServiceModel.cs
@@ -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:
+ }
+}
diff --git a/AJS.Web/Areas/Api/AdsController.cs b/AJS.Web/Areas/Api/AdsController.cs
index 2df2789..3d3fc2a 100644
--- a/AJS.Web/Areas/Api/AdsController.cs
+++ b/AJS.Web/Areas/Api/AdsController.cs
@@ -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
@@ -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 Get()
{
- return new JsonResult("");
+ var ads = await adsApiService.GetAllAds();
+ var result = mapper.Map(ads);
+ return new JsonResult(result);
}
- [HttpGet]
- [Route("GetById")]
- public async Task GetById()
+ [HttpGet("GetById/{id}")]
+ public async Task GetById(string id)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByCategory")]
- public async Task GetByCategory()
+ [HttpGet("GetByCategory/{categoryName}")]
+ public async Task GetByCategory(string categoryName)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByDate")]
- public async Task GetByDate()
+ [HttpGet("GetByDate/{publicationDate:datetime}")]
+ public async Task GetByDate(DateTime publicationDate)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByLastDateSync")]
- public async Task GetByLastDateSync()
+ [HttpGet("GetByLastDateSync/{lastSyncDate:datetime}")]
+ public async Task GetByLastDateSync(DateTime lastSyncDate)
{
return new JsonResult("");
}
diff --git a/AJS.Web/Areas/Api/JobsController.cs b/AJS.Web/Areas/Api/JobsController.cs
index 6ab9921..3410a26 100644
--- a/AJS.Web/Areas/Api/JobsController.cs
+++ b/AJS.Web/Areas/Api/JobsController.cs
@@ -1,5 +1,6 @@
using AJS.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
+using System;
using System.Threading.Tasks;
namespace AJS.Web.Areas.Api
@@ -19,37 +20,32 @@ public JobsController(IJobsApiService jobsApiService)
this.jobsApiService = jobsApiService;
}
- [HttpGet]
- [Route("Get")]
+ [HttpGet("Get")]
public async Task Get()
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetById")]
- public async Task GetById()
+ [HttpGet("GetById/{id}")]
+ public async Task GetById(string id)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByCategory")]
- public async Task GetByCategory()
+ [HttpGet("GetByCategory/{categoryName}")]
+ public async Task GetByCategory(string categoryName)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByDate")]
- public async Task GetByDate()
+ [HttpGet("GetByDate/{publicationDate:datetime}")]
+ public async Task GetByDate(DateTime publicationDate)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByLastDateSync")]
- public async Task GetByLastDateSync()
+ [HttpGet("GetByLastDateSync/{lastSyncDate:datetime}")]
+ public async Task GetByLastDateSync(DateTime lastSyncDate)
{
return new JsonResult("");
}
diff --git a/AJS.Web/Areas/Api/Models/AdApiModel.cs b/AJS.Web/Areas/Api/Models/AdApiModel.cs
new file mode 100644
index 0000000..a252f1c
--- /dev/null
+++ b/AJS.Web/Areas/Api/Models/AdApiModel.cs
@@ -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
+ {
+ }
+}
diff --git a/AJS.Web/Areas/Api/NewsController.cs b/AJS.Web/Areas/Api/NewsController.cs
index 731a136..f3e74ab 100644
--- a/AJS.Web/Areas/Api/NewsController.cs
+++ b/AJS.Web/Areas/Api/NewsController.cs
@@ -1,4 +1,5 @@
-using System.Threading.Tasks;
+using System;
+using System.Threading.Tasks;
using AJS.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
@@ -19,37 +20,32 @@ public NewsController(INewsApiService newsApiService)
this.newsApiService = newsApiService;
}
- [HttpGet]
- [Route("Get")]
+ [HttpGet("Get")]
public async Task Get()
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetById")]
- public async Task GetById()
+ [HttpGet("GetById/{id}")]
+ public async Task GetById(string id)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByCategory")]
- public async Task GetByCategory()
+ [HttpGet("GetByCategory/{categoryName}")]
+ public async Task GetByCategory(string categoryName)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByDate")]
- public async Task GetByDate()
+ [HttpGet("GetByDate/{publicationDate:datetime}")]
+ public async Task GetByDate(DateTime publicationDate)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByLastDateSync")]
- public async Task GetByLastDateSync()
+ [HttpGet("GetByLastDateSync/{lastSyncDate:datetime}")]
+ public async Task GetByLastDateSync(DateTime lastSyncDate)
{
return new JsonResult("");
}
diff --git a/AJS.Web/Areas/Api/ServicesController.cs b/AJS.Web/Areas/Api/ServicesController.cs
index a1233e7..4574a77 100644
--- a/AJS.Web/Areas/Api/ServicesController.cs
+++ b/AJS.Web/Areas/Api/ServicesController.cs
@@ -1,5 +1,6 @@
using AJS.Services.Interfaces;
using Microsoft.AspNetCore.Mvc;
+using System;
using System.Threading.Tasks;
namespace AJS.Web.Areas.Api
@@ -19,37 +20,32 @@ public ServicesController(IServicesApiService servicesApiService)
this.servicesApiService = servicesApiService;
}
- [HttpGet]
- [Route("Get")]
+ [HttpGet("Get")]
public async Task Get()
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetById")]
- public async Task GetById()
+ [HttpGet("GetById/{id}")]
+ public async Task GetById(string id)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByCategory")]
- public async Task GetByCategory()
+ [HttpGet("GetByCategory/{categoryName}")]
+ public async Task GetByCategory(string categoryName)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByDate")]
- public async Task GetByDate()
+ [HttpGet("GetByDate/{publicationDate:datetime}")]
+ public async Task GetByDate(DateTime publicationDate)
{
return new JsonResult("");
}
- [HttpGet]
- [Route("GetByLastDateSync")]
- public async Task GetByLastDateSync()
+ [HttpGet("GetByLastDateSync/{lastSyncDate:datetime}")]
+ public async Task GetByLastDateSync(DateTime lastSyncDate)
{
return new JsonResult("");
}