From 6fecd22ce809e9a4dae66fa3a1d26c43790ba426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borja=20Garc=C3=ADa=20Rodr=C3=ADguez?= Date: Mon, 21 Dec 2020 13:21:53 +0100 Subject: [PATCH] update mvc references --- src/Web/WebMVC/AppSettings.cs | 1 - .../WebMVC/Controllers/CampaignsController.cs | 100 --------------- src/Web/WebMVC/Infrastructure/API.cs | 21 ---- src/Web/WebMVC/Services/CampaignService.cs | 49 -------- src/Web/WebMVC/Services/ICampaignService.cs | 13 -- src/Web/WebMVC/Services/ILocationService.cs | 10 -- src/Web/WebMVC/Services/LocationService.cs | 38 ------ src/Web/WebMVC/Startup.cs | 7 -- .../CampaignViewModel/CampaignViewModel.cs | 20 --- src/Web/WebMVC/Views/Campaigns/Details.cshtml | 31 ----- src/Web/WebMVC/Views/Campaigns/Index.cshtml | 79 ------------ .../WebMVC/Views/Campaigns/_campaign.cshtml | 23 ---- .../WebMVC/Views/Campaigns/_pagination.cshtml | 32 ----- src/Web/WebMVC/Views/Shared/_Layout.cshtml | 1 - .../WebMVC/Views/Shared/_LoginPartial.cshtml | 8 -- src/Web/WebMVC/appsettings.json | 2 - .../css/campaigns/campaigns.component.css | 116 ------------------ 17 files changed, 551 deletions(-) delete mode 100644 src/Web/WebMVC/Controllers/CampaignsController.cs delete mode 100644 src/Web/WebMVC/Services/CampaignService.cs delete mode 100644 src/Web/WebMVC/Services/ICampaignService.cs delete mode 100644 src/Web/WebMVC/Services/ILocationService.cs delete mode 100644 src/Web/WebMVC/Services/LocationService.cs delete mode 100644 src/Web/WebMVC/ViewModels/CampaignViewModel/CampaignViewModel.cs delete mode 100644 src/Web/WebMVC/Views/Campaigns/Details.cshtml delete mode 100644 src/Web/WebMVC/Views/Campaigns/Index.cshtml delete mode 100644 src/Web/WebMVC/Views/Campaigns/_campaign.cshtml delete mode 100644 src/Web/WebMVC/Views/Campaigns/_pagination.cshtml delete mode 100644 src/Web/WebMVC/wwwroot/css/campaigns/campaigns.component.css diff --git a/src/Web/WebMVC/AppSettings.cs b/src/Web/WebMVC/AppSettings.cs index a705c5a90..dd0c25f1f 100644 --- a/src/Web/WebMVC/AppSettings.cs +++ b/src/Web/WebMVC/AppSettings.cs @@ -8,7 +8,6 @@ namespace Microsoft.eShopOnContainers.WebMVC public class AppSettings { //public Connectionstrings ConnectionStrings { get; set; } - public string MarketingUrl { get; set; } public string PurchaseUrl { get; set; } public string SignalrHubUrl { get; set; } public bool ActivateCampaignDetailFunction { get; set; } diff --git a/src/Web/WebMVC/Controllers/CampaignsController.cs b/src/Web/WebMVC/Controllers/CampaignsController.cs deleted file mode 100644 index 920269467..000000000 --- a/src/Web/WebMVC/Controllers/CampaignsController.cs +++ /dev/null @@ -1,100 +0,0 @@ -namespace Microsoft.eShopOnContainers.WebMVC.Controllers -{ - using AspNetCore.Authorization; - using AspNetCore.Mvc; - using global::WebMVC.Services.ModelDTOs; - using global::WebMVC.Services; - using global::WebMVC.ViewModels; - using Microsoft.Extensions.Options; - using Services; - using System; - using System.Threading.Tasks; - using ViewModels; - using ViewModels.Pagination; - using Microsoft.AspNetCore.Authentication.OpenIdConnect; - - [Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)] - public class CampaignsController : Controller - { - private readonly ICampaignService _campaignService; - private readonly ILocationService _locationService; - private readonly AppSettings _settings; - - public CampaignsController(ICampaignService campaignService, ILocationService locationService, IOptionsSnapshot settings) - { - _campaignService = campaignService; - _settings = settings.Value; - _locationService = locationService; - } - - public async Task Index(int page = 0, int pageSize = 10) - { - var campaignList = await _campaignService.GetCampaigns(pageSize, page); - - if(campaignList is null) - { - return View(); - } - - var totalPages = (int) Math.Ceiling((decimal) campaignList.Count / pageSize); - - var vm = new CampaignViewModel - { - CampaignItems = campaignList.Data, - PaginationInfo = new PaginationInfo - { - ActualPage = page, - ItemsPerPage = campaignList.Data.Count, - TotalItems = campaignList.Count, - TotalPages = totalPages, - Next = page == totalPages - 1 ? "is-disabled" : "", - Previous = page == 0 ? "is-disabled" : "" - } - }; - - ViewBag.IsCampaignDetailFunctionActive = _settings.ActivateCampaignDetailFunction; - - return View(vm); - } - - public async Task Details(int id) - { - var campaignDto = await _campaignService.GetCampaignById(id); - - if (campaignDto is null) - { - return NotFound(); - } - - var campaign = new CampaignItem - { - Id = campaignDto.Id, - Name = campaignDto.Name, - Description = campaignDto.Description, - From = campaignDto.From, - To = campaignDto.To, - PictureUri = campaignDto.PictureUri - }; - - return View(campaign); - } - - [HttpPost] - public async Task CreateNewUserLocation(CampaignViewModel model) - { - if (ModelState.IsValid) - { - var location = new LocationDTO() - { - Longitude = model.Lon, - Latitude = model.Lat - }; - await _locationService.CreateOrUpdateUserLocation(location); - - return RedirectToAction(nameof(Index)); - } - - return View(nameof(Index), model); - } - } -} \ No newline at end of file diff --git a/src/Web/WebMVC/Infrastructure/API.cs b/src/Web/WebMVC/Infrastructure/API.cs index b601282e0..0faeeb886 100644 --- a/src/Web/WebMVC/Infrastructure/API.cs +++ b/src/Web/WebMVC/Infrastructure/API.cs @@ -82,26 +82,5 @@ return $"{baseUri}catalogTypes"; } } - - public static class Marketing - { - public static string GetAllCampaigns(string baseUri, int take, int page) - { - return $"{baseUri}user?pageSize={take}&pageIndex={page}"; - } - - public static string GetAllCampaignById(string baseUri, int id) - { - return $"{baseUri}{id}"; - } - } - - public static class Locations - { - public static string CreateOrUpdateUserLocation(string baseUri) - { - return baseUri; - } - } } } \ No newline at end of file diff --git a/src/Web/WebMVC/Services/CampaignService.cs b/src/Web/WebMVC/Services/CampaignService.cs deleted file mode 100644 index d768c51fd..000000000 --- a/src/Web/WebMVC/Services/CampaignService.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace Microsoft.eShopOnContainers.WebMVC.Services -{ - using global::WebMVC.Infrastructure; - using Microsoft.Extensions.Logging; - using Microsoft.Extensions.Options; - using Newtonsoft.Json; - using System.Net.Http; - using System.Threading.Tasks; - using ViewModels; - - public class CampaignService : ICampaignService - { - private readonly IOptions _settings; - private readonly HttpClient _httpClient; - private readonly ILogger _logger; - private readonly string _remoteServiceBaseUrl; - - public CampaignService(IOptions settings, HttpClient httpClient, ILogger logger) - { - _settings = settings; - _httpClient = httpClient; - _logger = logger; - - _remoteServiceBaseUrl = $"{_settings.Value.MarketingUrl}/m/api/v1/campaigns/"; - } - - public async Task GetCampaigns(int pageSize, int pageIndex) - { - var uri = API.Marketing.GetAllCampaigns(_remoteServiceBaseUrl, pageSize, pageIndex); - - var responseString = await _httpClient.GetStringAsync(uri); - - var response = JsonConvert.DeserializeObject(responseString); - - return response; - } - - public async Task GetCampaignById(int id) - { - var uri = API.Marketing.GetAllCampaignById(_remoteServiceBaseUrl, id); - - var responseString = await _httpClient.GetStringAsync(uri); - - var response = JsonConvert.DeserializeObject(responseString); - - return response; - } - } -} \ No newline at end of file diff --git a/src/Web/WebMVC/Services/ICampaignService.cs b/src/Web/WebMVC/Services/ICampaignService.cs deleted file mode 100644 index ab80e930a..000000000 --- a/src/Web/WebMVC/Services/ICampaignService.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Microsoft.eShopOnContainers.WebMVC.Services -{ - using System.Collections.Generic; - using System.Threading.Tasks; - using ViewModels; - - public interface ICampaignService - { - Task GetCampaigns(int pageSize, int pageIndex); - - Task GetCampaignById(int id); - } -} \ No newline at end of file diff --git a/src/Web/WebMVC/Services/ILocationService.cs b/src/Web/WebMVC/Services/ILocationService.cs deleted file mode 100644 index d5f7b7224..000000000 --- a/src/Web/WebMVC/Services/ILocationService.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Threading.Tasks; -using WebMVC.Services.ModelDTOs; - -namespace WebMVC.Services -{ - public interface ILocationService - { - Task CreateOrUpdateUserLocation(LocationDTO location); - } -} diff --git a/src/Web/WebMVC/Services/LocationService.cs b/src/Web/WebMVC/Services/LocationService.cs deleted file mode 100644 index 4619cfd6a..000000000 --- a/src/Web/WebMVC/Services/LocationService.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.eShopOnContainers.WebMVC; -using Microsoft.eShopOnContainers.WebMVC.Services; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Newtonsoft.Json; -using System.Net.Http; -using System.Threading.Tasks; -using WebMVC.Infrastructure; -using WebMVC.Services.ModelDTOs; - -namespace WebMVC.Services -{ - public class LocationService : ILocationService - { - private readonly IOptions _settings; - private readonly HttpClient _httpClient; - private readonly ILogger _logger; - private readonly string _remoteServiceBaseUrl; - - public LocationService(HttpClient httpClient, IOptions settings, ILogger logger) - { - _httpClient = httpClient; - _settings = settings; - _logger = logger; - - _remoteServiceBaseUrl = $"{_settings.Value.MarketingUrl}/l/api/v1/locations/"; - } - - public async Task CreateOrUpdateUserLocation(LocationDTO location) - { - var uri = API.Locations.CreateOrUpdateUserLocation(_remoteServiceBaseUrl); - var locationContent = new StringContent(JsonConvert.SerializeObject(location), System.Text.Encoding.UTF8, "application/json"); - - var response = await _httpClient.PostAsync(uri, locationContent); - response.EnsureSuccessStatusCode(); - } - } -} diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index e438e9d6c..01d607e61 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -175,13 +175,6 @@ namespace Microsoft.eShopOnContainers.WebMVC .AddHttpMessageHandler() .AddDevspacesSupport(); - services.AddHttpClient() - .AddHttpMessageHandler() - .AddDevspacesSupport(); - - services.AddHttpClient() - .AddHttpMessageHandler() - .AddDevspacesSupport(); //add custom application services services.AddTransient, IdentityParser>(); diff --git a/src/Web/WebMVC/ViewModels/CampaignViewModel/CampaignViewModel.cs b/src/Web/WebMVC/ViewModels/CampaignViewModel/CampaignViewModel.cs deleted file mode 100644 index 80018202f..000000000 --- a/src/Web/WebMVC/ViewModels/CampaignViewModel/CampaignViewModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace WebMVC.ViewModels -{ - using System.Collections.Generic; - using Microsoft.eShopOnContainers.WebMVC.ViewModels; - using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination; - using WebMVC.ViewModels.Annotations; - using Newtonsoft.Json; - using System.ComponentModel.DataAnnotations; - - public class CampaignViewModel - { - public IEnumerable CampaignItems { get; set; } - public PaginationInfo PaginationInfo { get; set; } - - [LongitudeCoordinate, Required] - public double Lon { get; set; } = -122.315752; - [LatitudeCoordinate, Required] - public double Lat { get; set; } = 47.604610; - } -} \ No newline at end of file diff --git a/src/Web/WebMVC/Views/Campaigns/Details.cshtml b/src/Web/WebMVC/Views/Campaigns/Details.cshtml deleted file mode 100644 index aaf0151b1..000000000 --- a/src/Web/WebMVC/Views/Campaigns/Details.cshtml +++ /dev/null @@ -1,31 +0,0 @@ -@model CampaignItem - -@{ - ViewData["Title"] = "Campaign details"; - - var headerList= new List
() { - new Header() { Controller = "Catalog", Text = "Back to catalog" }, - new Header() { Controller = "Campaigns", Text = "Back to Campaigns" } }; -} -
-
- -
-
- - - -
-
- Card image cap -
-

@Model.Name

-

@Model.Description

-
- -
-
\ No newline at end of file diff --git a/src/Web/WebMVC/Views/Campaigns/Index.cshtml b/src/Web/WebMVC/Views/Campaigns/Index.cshtml deleted file mode 100644 index 38d0d623c..000000000 --- a/src/Web/WebMVC/Views/Campaigns/Index.cshtml +++ /dev/null @@ -1,79 +0,0 @@ -@model WebMVC.ViewModels.CampaignViewModel - -@{ - ViewData["Title"] = "Campaigns"; - - var headerList= new List
() { - new Header() { Controller = "Catalog", Text = "Back to catalog" } }; -} - -
-
- -
-
- - - -
-
-
- - @if (!ViewData.ModelState.IsValid) - { -
- @Html.ValidationSummary(false) -
- } - -
-
- UPDATE USER LOCATION -
-
-
- - -
-
- Lat -
- -
- -
-
- Lon -
- -
- -
- -
-
-
-
-
- @if (Model != null && Model.CampaignItems !=null && Model.CampaignItems.Any()) - { -
- @foreach (var catalogItem in Model.CampaignItems) - { -
- -
- } -
- - - } - else - { -
- THERE ARE NO CAMPAIGNS -
- } -
- - diff --git a/src/Web/WebMVC/Views/Campaigns/_campaign.cshtml b/src/Web/WebMVC/Views/Campaigns/_campaign.cshtml deleted file mode 100644 index 260e76555..000000000 --- a/src/Web/WebMVC/Views/Campaigns/_campaign.cshtml +++ /dev/null @@ -1,23 +0,0 @@ -@model CampaignItem - -
-
- @Model.Name -
-

@Model.Name

- @if (ViewBag.IsCampaignDetailFunctionActive == true) - { - - } - else - { - - } -
- -
-
diff --git a/src/Web/WebMVC/Views/Campaigns/_pagination.cshtml b/src/Web/WebMVC/Views/Campaigns/_pagination.cshtml deleted file mode 100644 index 038222e93..000000000 --- a/src/Web/WebMVC/Views/Campaigns/_pagination.cshtml +++ /dev/null @@ -1,32 +0,0 @@ -@model Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination.PaginationInfo - -
-
-
- -
-
-
- diff --git a/src/Web/WebMVC/Views/Shared/_Layout.cshtml b/src/Web/WebMVC/Views/Shared/_Layout.cshtml index ee0c724c4..9a634b78a 100644 --- a/src/Web/WebMVC/Views/Shared/_Layout.cshtml +++ b/src/Web/WebMVC/Views/Shared/_Layout.cshtml @@ -13,7 +13,6 @@ - diff --git a/src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml b/src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml index f3ce6a729..1b9cde79d 100644 --- a/src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml +++ b/src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml @@ -26,14 +26,6 @@ - - -
Campaigns
- -
- diff --git a/src/Web/WebMVC/appsettings.json b/src/Web/WebMVC/appsettings.json index 436baedb6..7c169c27c 100644 --- a/src/Web/WebMVC/appsettings.json +++ b/src/Web/WebMVC/appsettings.json @@ -2,10 +2,8 @@ "CatalogUrl": "http://localhost:5101", "OrderingUrl": "http://localhost:5102", "BasketUrl": "http://localhost:5103", - "MarketingUrl": "http://localhost:5110", "IdentityUrl": "http://localhost:5105", "CallBackUrl": "http://localhost:5100/", - "LocationsUrl": "http://localhost:5109/", "IsClusterEnv": "False", "UseResilientHttp": "True", "UseLoadTest": false, diff --git a/src/Web/WebMVC/wwwroot/css/campaigns/campaigns.component.css b/src/Web/WebMVC/wwwroot/css/campaigns/campaigns.component.css deleted file mode 100644 index e65758db7..000000000 --- a/src/Web/WebMVC/wwwroot/css/campaigns/campaigns.component.css +++ /dev/null @@ -1,116 +0,0 @@ -.esh-campaigns-hero { - background-image: url("../../images/main_banner.png"); - background-size: cover; - height: 260px; - width: 100%; -} - -.esh-campaigns-title { - position: relative; - top: 74.28571px; -} - - .esh-campaigns-label::before { - color: rgba(255, 255, 255, 0.5); - content: attr(data-title); - font-size: 0.65rem; - margin-top: 0.65rem; - margin-left: 0.5rem; - position: absolute; - text-transform: uppercase; - z-index: 1; - } - - .esh-campaigns-label::after { - background-image: url("../../images/arrow-down.png"); - height: 7px; - content: ''; - position: absolute; - right: 1.5rem; - top: 2.5rem; - width: 10px; - z-index: 1; - } - -.esh-campaigns-items { - margin-top: 1rem; -} - -.esh-campaigns-item { - text-align: center; - margin-bottom: 1.5rem; - width: 33%; - display: inline-block; - float: none !important; -} - -@media screen and (max-width: 1024px) { - .esh-campaigns-item { - width: 50%; - } -} - -@media screen and (max-width: 768px) { - .esh-campaigns-item { - width: 100%; - } -} - -.esh-campaigns-thumbnail { - max-width: 370px; - width: 100%; -} - -.esh-campaigns-button { - background-color: #83D01B; - border: none; - color: #FFFFFF; - cursor: pointer; - font-size: 1rem; - height: 3rem; - margin-top: 1rem; - transition: all 0.35s; - width: 80%; -} - -.esh-campaigns-card-footer-text { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} - -.esh-campaigns-form-button { - background-color: #83D01B; - border: none; - color: #FFFFFF; - cursor: pointer; - font-size: 1rem; - transition: all 0.35s; - width: 80%; - margin-top: -15px; -} - - .esh-campaigns-button.is-disabled { - opacity: .5; - pointer-events: none; - } - - .esh-campaigns-button:hover { - background-color: #4a760f; - transition: all 0.35s; - } - -.esh-campaigns-name { - font-size: 1rem; - font-weight: 300; - margin-top: .5rem; - text-align: center; - text-transform: uppercase; -} - -.esh-campaigns-description { - text-align: center; - font-weight: 300; - font-size: 14px; -} -