got Abstraction
This commit is contained in:
parent
28667942c4
commit
36002d8ef8
11 changed files with 118 additions and 80 deletions
|
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
|||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using System.Linq;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
|
@ -148,5 +149,36 @@ namespace Yavsc.Controllers
|
|||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> DeleteAllLike(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
Bug bugref = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bugref == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var bugs = _context.Bug.Where(b => b.Description == bugref.Description);
|
||||
return View(bugs);
|
||||
}
|
||||
|
||||
// POST: Bug/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> DeleteAllLikeConfirmed(long id)
|
||||
{
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
var bugs = await _context.Bug.Where(b => b.Description == bug.Description).ToArrayAsync();
|
||||
foreach (var btd in bugs)
|
||||
_context.Bug.Remove(btd);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,18 @@ namespace Yavsc.Services
|
|||
{
|
||||
readonly SiteSettings siteSettings;
|
||||
readonly SmtpSettings smtpSettings;
|
||||
private readonly ILogger logger;
|
||||
|
||||
public MailSender(
|
||||
IOptions<SiteSettings> sitesOptions,
|
||||
IOptions<SmtpSettings> smtpOptions
|
||||
IOptions<SmtpSettings> smtpOptions,
|
||||
ILoggerFactory loggerFactory
|
||||
)
|
||||
{
|
||||
siteSettings = sitesOptions?.Value;
|
||||
smtpSettings = smtpOptions?.Value;
|
||||
logger = loggerFactory.CreateLogger<MailSender>();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -40,6 +44,7 @@ namespace Yavsc.Services
|
|||
EmailSentViewModel model = new EmailSentViewModel{ EMail = email };
|
||||
try
|
||||
{
|
||||
logger.LogInformation($"SendEmailAsync for {email}: {message}");
|
||||
MimeMessage msg = new MimeMessage();
|
||||
msg.From.Add(new MailboxAddress(
|
||||
siteSettings.Owner.Name,
|
||||
|
|
@ -59,6 +64,7 @@ namespace Yavsc.Services
|
|||
smtpSettings.Host,
|
||||
smtpSettings.Port,
|
||||
SecureSocketOptions.Auto);
|
||||
|
||||
if (smtpSettings.UserName!=null) {
|
||||
NetworkCredential creds = new NetworkCredential(
|
||||
smtpSettings.UserName, smtpSettings.Password, smtpSettings.Domain);
|
||||
|
|
@ -68,6 +74,7 @@ namespace Yavsc.Services
|
|||
await sc.SendAsync(msg);
|
||||
model.MessageId = msg.MessageId;
|
||||
model.Sent = true; // a duplicate info to remove from the view model, that equals to MessageId == null
|
||||
logger.LogInformation($"Sent : {msg}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -398,6 +398,7 @@ namespace Yavsc
|
|||
options.AuthenticationDescriptions.Clear();
|
||||
options.AutomaticAuthentication = false;
|
||||
});
|
||||
|
||||
app.UseSession();
|
||||
|
||||
ConfigureOAuthApp(app);
|
||||
|
|
|
|||
53
src/Yavsc/Views/Bug/DeleteAllLike.cshtml
Normal file
53
src/Yavsc/Views/Bug/DeleteAllLike.cshtml
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
@model IEnumerable<Yavsc.Models.IT.Fixing.Bug>
|
||||
@inject IStringLocalizer<Yavsc.Models.IT.Fixing.Resources> SRR
|
||||
|
||||
@{
|
||||
ViewData["Title"] = @SR["DeleteAllLike"];
|
||||
}
|
||||
|
||||
<h2>@SR["Index"]</h2>
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">@SR["Create New"]</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>
|
||||
@SR[Html.DisplayNameFor(model => model.Id)]
|
||||
</td>
|
||||
<td>
|
||||
@SR[Html.DisplayNameFor(model => model.Title)]
|
||||
</td>
|
||||
<th>
|
||||
@SR[Html.DisplayNameFor(model => model.FeatureId)]
|
||||
</th>
|
||||
<th>
|
||||
@SR[Html.DisplayNameFor(model => model.Status)]
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(model => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(model => item.Title)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FeatureId)
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@SRR[typeof(Yavsc.Models.IT.Fixing.BugStatus).GetEnumNames()[(int)item.Status]]
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@item.Id">@SR["Edit"]</a> |
|
||||
<a asp-action="Details" asp-route-id="@item.Id">@SR["Details"]</a> |
|
||||
<a asp-action="DeleteAllLike" asp-route-id="@item.Id">@SR["Delete"]</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
Loading…
Add table
Add a link
Reference in a new issue