Add details view and add marketing scope in mvc project and identity config
This commit is contained in:
parent
91de998506
commit
e80c5efdd3
@ -108,7 +108,8 @@ namespace Identity.API.Configuration
|
||||
IdentityServerConstants.StandardScopes.OfflineAccess,
|
||||
"orders",
|
||||
"basket",
|
||||
"locations"
|
||||
"locations",
|
||||
"marketing"
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -11,19 +11,23 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
[Route("api/v1/[controller]")]
|
||||
[Authorize]
|
||||
public class CampaignsController : Controller
|
||||
{
|
||||
private readonly MarketingContext _context;
|
||||
private readonly MarketingSettings _settings;
|
||||
private readonly IMarketingDataRepository _marketingDataRepository;
|
||||
|
||||
public CampaignsController(MarketingContext context,
|
||||
IMarketingDataRepository marketingDataRepository)
|
||||
IMarketingDataRepository marketingDataRepository,
|
||||
IOptionsSnapshot<MarketingSettings> settings)
|
||||
{
|
||||
_context = context;
|
||||
_marketingDataRepository = marketingDataRepository;
|
||||
_settings = settings.Value;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -171,7 +175,7 @@
|
||||
Description = campaign.Description,
|
||||
From = campaign.From,
|
||||
To = campaign.To,
|
||||
PictureUri = campaign.PictureUri
|
||||
PictureUri = GetUriPlaceholder(campaign.PictureUri)
|
||||
};
|
||||
}
|
||||
|
||||
@ -184,8 +188,17 @@
|
||||
Description = campaignDto.Description,
|
||||
From = campaignDto.From,
|
||||
To = campaignDto.To,
|
||||
PictureUri = $"http://externalcatalogbaseurltobereplaced/api/v1/campaigns/{campaignDto.Id}/pic"
|
||||
PictureUri = campaignDto.PictureUri
|
||||
};
|
||||
}
|
||||
|
||||
private string GetUriPlaceholder(string campaignUri)
|
||||
{
|
||||
var baseUri = _settings.ExternalCatalogBaseUrl;
|
||||
|
||||
campaignUri = campaignUri.Replace("http://externalcatalogbaseurltobereplaced", baseUri);
|
||||
|
||||
return campaignUri;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,5 +5,6 @@
|
||||
public string ConnectionString { get; set; }
|
||||
public string MongoConnectionString { get; set; }
|
||||
public string MongoDatabase { get; set; }
|
||||
public string ExternalCatalogBaseUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
"ConnectionString": "127.0.0.1",
|
||||
"MongoConnectionString": "mongodb://nosql.data",
|
||||
"MongoDatabase": "MarketingDb",
|
||||
"IdentityUrl": "http://localhost:5105"
|
||||
"IdentityUrl": "http://localhost:5105",
|
||||
"ExternalCatalogBaseUrl": "http://localhost:5110"
|
||||
}
|
||||
|
@ -83,7 +83,17 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
||||
|
||||
public async Task<IActionResult> Details(int id)
|
||||
{
|
||||
var campaign = await _campaignService.GetCampaignById(id);
|
||||
var campaignDto = await _campaignService.GetCampaignById(id);
|
||||
|
||||
var campaign = new Campaign
|
||||
{
|
||||
Id = campaignDto.Id,
|
||||
Name = campaignDto.Name,
|
||||
Description = campaignDto.Description,
|
||||
From = campaignDto.From,
|
||||
To = campaignDto.To,
|
||||
PictureUri = campaignDto.PictureUri
|
||||
};
|
||||
|
||||
return View(campaign);
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
||||
SaveTokens = true,
|
||||
GetClaimsFromUserInfoEndpoint = true,
|
||||
RequireHttpsMetadata = false,
|
||||
Scope = { "openid", "profile", "orders", "basket" }
|
||||
Scope = { "openid", "profile", "orders", "basket", "marketing" }
|
||||
};
|
||||
|
||||
//Wait untill identity service is ready on compose.
|
||||
|
28
src/Web/WebMVC/Views/Campaigns/Details.cshtml
Normal file
28
src/Web/WebMVC/Views/Campaigns/Details.cshtml
Normal file
@ -0,0 +1,28 @@
|
||||
@{
|
||||
ViewData["Title"] = "Campaign details";
|
||||
@model Microsoft.eShopOnContainers.WebMVC.ViewModels.Campaign
|
||||
}
|
||||
<section class="esh-campaigns-hero">
|
||||
<div class="container">
|
||||
<img class="esh-campaigns-title" src="~/images/main_banner_text.png" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@Html.Partial("_Header", new List<Header>() {
|
||||
new Header() { Controller = "Catalog", Text = "Back to catalog" },
|
||||
new Header() { Controller = "Campaigns", Text = "Back to Campaigns" } })
|
||||
|
||||
<div class="container">
|
||||
<div class="card esh-campaigns-items">
|
||||
<img class="card-img-top" src="@Model.PictureUri" alt="Card image cap">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">@Model.Name</h4>
|
||||
<p class="card-text">@Model.Description</p>
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
From @Model.From.ToString("MMMM dd, yyyy") until @Model.To.ToString("MMMM dd, yyyy")
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -20,15 +20,15 @@
|
||||
<form asp-controller="Campaigns" asp-action="Details" asp-route-id="@campaign.Id">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title esh-campaigns-name">@campaign.Name</h4>
|
||||
<p class="card-text esh-campaigns-description">@campaign.Description</p>
|
||||
<img class="card-img-top esh-campaigns-thumbnail" src="@campaign.PictureUri" alt="@campaign.Name">
|
||||
<input class="esh-campaigns-button" type="submit" value="More details">
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
|
||||
<small class="text-muted">
|
||||
From @campaign.From.ToString("MMMM dd, yyyy") until @campaign.To.ToString("MMMM dd, yyyy")
|
||||
</small>
|
||||
</div>
|
||||
<input class="esh-campaigns-button" type="submit" value="More details">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
|
@ -117,9 +117,11 @@
|
||||
{
|
||||
return new CampaignDTO()
|
||||
{
|
||||
Name = "FakeCampaignName",
|
||||
Description = "FakeCampaignDescription",
|
||||
From = DateTime.Now,
|
||||
To = DateTime.Now.AddDays(7),
|
||||
PictureUri = "http://externalcatalogbaseurltobereplaced/api/v1/campaigns/0/pic"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user