Skip to content

Commit 46e26c4

Browse files
committed
email test
1 parent 5a5fc12 commit 46e26c4

File tree

12 files changed

+102
-49
lines changed

12 files changed

+102
-49
lines changed

ClientApp/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Collapse from "./collapse";
22
import { navInit } from "./navbar";
3-
import { swiperDefault, swiperParallax } from "./swipers/swiper-default";
3+
import { swiperDefault, swiperSponsor } from "./swipers/swiper-default";
44

55
navInit();
66
new Collapse();
77
swiperDefault();
8-
swiperParallax();
8+
swiperSponsor();
+18-15
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
import Swiper from 'swiper';
2+
import { Autoplay, Pagination, Navigation } from 'swiper/modules';
23
import 'swiper/css';
4+
import 'swiper/css/navigation';
5+
import 'swiper/css/pagination';
36

47
export function swiperDefault() {
58
new Swiper(".js-swiper-default", {
69
slidesPerView: 1,
710
loop: true,
8-
autoplay: true,
11+
autoplay: {
12+
delay: 2500
13+
},
14+
modules: [Autoplay, Pagination, Navigation],
915
pagination: {
1016
el: ".swiper-pagination",
1117
clickable: true
1218
}
1319
});
1420
}
1521

16-
export function swiperParallax() {
17-
const selector = document.querySelector('.js-swiper-parallax') as HTMLElement;
22+
export function swiperSponsor() {
23+
const selector = document.querySelector('.js-swiper-sponsor') as HTMLElement;
1824
if (!selector) {
1925
return;
2026
}
21-
new Swiper(".js-swiper-parallax", {
22-
slidesPerView: 2,
27+
new Swiper(".js-swiper-sponsor", {
2328
spaceBetween: 30,
24-
pagination: {
25-
el: ".swiper-pagination",
26-
clickable: true,
27-
},
28-
autoplay: true,
2929
loop: true,
30+
autoplay: true,
3031
breakpoints: {
32+
0: {
33+
slidesPerView: 2,
34+
},
3135
768: {
32-
slidesPerView: 6,
33-
spaceBetween: 30
36+
slidesPerView: 6
3437
},
3538
1024: {
36-
slidesPerView: 8,
37-
spaceBetween: 40
39+
slidesPerView: 8
3840
}
39-
}
41+
},
42+
modules: [Autoplay, Navigation]
4043
});
4144
}

Controllers/AppSettingController.cs

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Microsoft.AspNetCore.Authorization;
2-
using Microsoft.AspNetCore.Identity;
1+
using Microsoft.AspNetCore.Identity;
2+
using Microsoft.AspNetCore.Identity.UI.Services;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.EntityFrameworkCore;
55
using System.Text.Json;
@@ -10,6 +10,8 @@
1010
using Waffle.ExternalAPI.Models;
1111
using Waffle.Models.Components;
1212
using Waffle.Models.Settings;
13+
using Waffle.UnitTest;
14+
using WFSendGrid = Waffle.ExternalAPI.SendGrids.SendGrid;
1315

1416
namespace Waffle.Controllers;
1517

@@ -21,15 +23,17 @@ public class AppSettingController : BaseController
2123
private readonly IFacebookService _facebookService;
2224
private readonly ITelegramService _telegramService;
2325
private readonly IWorkService _workService;
26+
private readonly IEmailSender _emailSender;
2427

25-
public AppSettingController(ApplicationDbContext context, IAppSettingService appSettingService, IConfiguration configuration, IFacebookService facebookService, ITelegramService telegramService, IWorkService workService)
28+
public AppSettingController(IEmailSender emailSender, ApplicationDbContext context, IAppSettingService appSettingService, IConfiguration configuration, IFacebookService facebookService, ITelegramService telegramService, IWorkService workService)
2629
{
2730
_context = context;
2831
_appSettingService = appSettingService;
2932
_configuration = configuration;
3033
_facebookService = facebookService;
3134
_telegramService = telegramService;
3235
_workService = workService;
36+
_emailSender = emailSender;
3337
}
3438

3539
[HttpGet("by-name/{normalizedName}")]
@@ -58,18 +62,14 @@ public IActionResult GetInfo()
5862
public async Task<IActionResult> GetSendGridAsync()
5963
{
6064
var app = await _appSettingService.EnsureSettingAsync(nameof(SendGrid));
61-
return base.Ok(await _appSettingService.GetAsync<ExternalAPI.SendGrids.SendGrid>(app.Id));
65+
return base.Ok(await _appSettingService.GetAsync<WFSendGrid>(app.Id));
6266
}
6367

6468
[HttpPost("sendgrid/save")]
65-
public async Task<IActionResult> SaveSendGridAsync([FromBody] ExternalAPI.SendGrids.SendGrid args)
69+
public async Task<IActionResult> SaveSendGridAsync([FromBody] WFSendGrid args)
6670
{
67-
var setting = await _context.AppSettings.FirstOrDefaultAsync(x => x.NormalizedName.Equals(nameof(SendGrid)));
68-
if (setting == null)
69-
{
70-
return Ok(IdentityResult.Failed());
71-
}
72-
setting.Value = JsonSerializer.Serialize(args);
71+
var app = await _appSettingService.EnsureSettingAsync(nameof(SendGrid));
72+
app.Value = JsonSerializer.Serialize(args);
7373
await _context.SaveChangesAsync();
7474
return Ok(IdentityResult.Success);
7575
}
@@ -202,4 +202,11 @@ public async Task<IActionResult> GetSidebarAsync()
202202

203203
[HttpPost("delete/work/{id}")]
204204
public async Task<IActionResult> DeleteWorkAsync([FromRoute] Guid id) => Ok(await _appSettingService.DeleteWorkAsync(id));
205+
206+
[HttpPost("test-send-mail")]
207+
public async Task<IActionResult> TestSendMailAsync([FromBody] EmailSenderMessageUnitTest args)
208+
{
209+
await _emailSender.SendEmailAsync(args.Email, args.Subject, args.Message);
210+
return Ok(args);
211+
}
205212
}

Core/Constants/UIHint.cs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Waffle.Core.Constants
2+
{
3+
public class UIHint
4+
{
5+
public const string Tags = nameof(Tags);
6+
}
7+
}

ExternalAPI/SendGrids/SendGrid.cs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class SendGrid
99
[JsonPropertyName("from")]
1010
public SendGridConfigureFrom From { get; set; } = new();
1111
}
12+
1213
public class SendGridConfigureFrom
1314
{
1415
[JsonPropertyName("email")]

Pages/Article/Details.cshtml

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
<i class="fas fa-tag mr-2"></i>
2626
@foreach (var item in Model.Tags)
2727
{
28-
<a href="/tag/@item.NormalizedName" class="wf-badge inline-block">@item.Name</a>
28+
<a href="/tag/@item.NormalizedName" class="bg-gray-100 px-2 py-1 inline-block rounded tag-item">@item.Name</a>
2929
}
30+
3031
</div>
3132
}
3233

Pages/Article/Details.cshtml.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Microsoft.AspNetCore.Identity;
22
using Microsoft.AspNetCore.Mvc;
33
using Microsoft.EntityFrameworkCore;
4+
using System.ComponentModel.DataAnnotations;
5+
using Waffle.Core.Constants;
46
using Waffle.Core.Foundations;
57
using Waffle.Core.Interfaces.IService;
68
using Waffle.Data;
@@ -26,6 +28,7 @@ public DetailsModel(ICatalogService catalogService, ApplicationDbContext context
2628
}
2729

2830
public List<WorkListItem> Works = new();
31+
[UIHint(UIHint.Tags)]
2932
public List<Catalog> Tags = new();
3033
public bool HasTag => Tags.Any();
3134
public Feed ProductFeed = new();

Pages/Article/Details.cshtml.css

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
.wf-badge {
2-
padding: .25rem 1rem;
3-
border-radius: 999px;
4-
font-size: .875rem;
5-
border: 1px solid var(--gray-200);
6-
color: var(--body-color);
1+
.tag-item:hover {
2+
color: white;
3+
background-color: var(--dark);
74
}
8-
.wf-badge:hover {
9-
background-color: var(--light);
10-
}

Pages/Shared/Components/Sponsor/Default.cshtml

+17-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
<div class="sponsor mb-4">
55
<div class="container">
66
<div class="title">Sponsors</div>
7-
@await Html.PartialAsync("/Pages/Shared/Components/Swiper/Parallax.cshtml", new Swiper {
8-
Id = new Guid(),
9-
Mode = "parallax",
10-
Items = Model.Brands.Select(x => new SwiperItem {
11-
Image = x.Logo,
12-
Title = x.Name,
13-
Url = x.Url
14-
}).ToList()
15-
})
7+
<div class="swiper js-swiper-sponsor">
8+
<div class="swiper-wrapper">
9+
@if (Model.Brands.Any())
10+
{
11+
@foreach (var item in Model.Brands)
12+
{
13+
<div class="swiper-slide">
14+
<div class="h-24 flex items-center justify-center">
15+
<a href="@item.Url" aria-label="@item.Name" rel="nofollow" target="_blank">
16+
<img src="@item.Logo" alt="@item.Name" class="w-full" loading="lazy" />
17+
</a>
18+
</div>
19+
</div>
20+
}
21+
}
22+
</div>
23+
</div>
1624
</div>
1725
</div>
1826

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@using Waffle.Entities
2+
@model IEnumerable<Catalog>
3+
4+
<div class="mb-4 tags">
5+
<div class="title">Tags</div>
6+
<div class="bg-white rounded flex flex-wrap gap-2">
7+
@foreach (var item in Model)
8+
{
9+
<a href="/tag/@item.NormalizedName" class="bg-gray-100 px-2 py-1 rounded tag-item">@item.Name</a>
10+
}
11+
</div>
12+
</div>

Pages/User/Register.cshtml

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
<input class="form-control" type="email" required name="email" />
3636
</div>
3737
<div class="form-item">
38-
<div class="form-label">Tên đăng nhập</div>
38+
<div class="form-label">
39+
Tên đăng nhập
40+
<font color="red">*</font>
41+
</div>
3942
<input class="form-control" type="text" required name="userName" />
4043
</div>
4144
<div class="form-item">
@@ -45,12 +48,14 @@
4548
<div class="form-item">
4649
<div class="form-label">
4750
<localize key="password" />
51+
<font color="red">*</font>
4852
</div>
4953
<input class="form-control" type="password" required name="Password" />
5054
</div>
5155
<div class="form-item">
5256
<div class="form-label">
5357
<localize key="confirmPassword" />
58+
<font color="red">*</font>
5459
</div>
5560
<input class="form-control" type="password" required name="ConfirmPassword" />
5661
</div>
@@ -70,7 +75,7 @@
7075
<div class="md:w-1/3">
7176
<div class="mb-4">
7277
Hoặc đăng ký qua
73-
</div>
78+
</div>
7479
<div class="mb-4">
7580
<a href="#" class="px-6 py-2 rounded border text-dark hover:bg-gray-100 block mb-2">
7681
<i class="fab fa-facebook mr-2"></i>Facebook

UnitTest/EmailSenderUnitTest.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Waffle.UnitTest
2+
{
3+
public class EmailSenderMessageUnitTest
4+
{
5+
public string Email { get; set; } = default!;
6+
public string Subject { get; set; } = default!;
7+
public string Message { get; set; } = default!;
8+
}
9+
public class EmailSenderUnitTest
10+
{
11+
}
12+
}

0 commit comments

Comments
 (0)