reorg
This commit is contained in:
parent
d000f77098
commit
40e8e08690
3487 changed files with 39 additions and 21 deletions
186
src/Yavsc.Org/Controllers/Survey/BugController.cs
Normal file
186
src/Yavsc.Org/Controllers/Survey/BugController.cs
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.IT.Fixing;
|
||||
using Yavsc.Models.IT.Evolution;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class BugController : Controller
|
||||
{
|
||||
readonly ApplicationDbContext _context;
|
||||
readonly IStringLocalizer<BugController> _localizer;
|
||||
readonly IStringLocalizer<Yavsc.Models.IT.Fixing.Resources> _statusLocalizer;
|
||||
|
||||
public BugController(ApplicationDbContext context,
|
||||
IStringLocalizer<BugController> localizer,
|
||||
IStringLocalizer<Resources> statusLocalizer
|
||||
)
|
||||
{
|
||||
_context = context;
|
||||
_localizer = localizer;
|
||||
_statusLocalizer = statusLocalizer;
|
||||
}
|
||||
|
||||
// GET: Bug
|
||||
public async Task<IActionResult> Index(int skip = 0, int take = 25)
|
||||
{
|
||||
if (take > 50) return BadRequest();
|
||||
ViewData["skip"]=skip;
|
||||
ViewData["take"]=take;
|
||||
return View(await _context.Bug.Skip(skip).Take(take).ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Bug/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bug == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(bug);
|
||||
}
|
||||
|
||||
// GET: Bug/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.Features = Features(_context);
|
||||
ViewBag.Statuses = Statuses(default(BugStatus));
|
||||
return View();
|
||||
}
|
||||
|
||||
IEnumerable<SelectListItem> Statuses(BugStatus ?status) =>
|
||||
_statusLocalizer.CreateSelectListItems(typeof(BugStatus), status);
|
||||
|
||||
IEnumerable<SelectListItem> Features(ApplicationDbContext context) =>
|
||||
context.Feature.CreateSelectListItems<Feature>(f => f.Id.ToString(), f => $"{f.ShortName} ({f.Description})", null)
|
||||
.AddNull(_localizer["noAttachedFID"]);
|
||||
|
||||
// POST: Bug/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Bug bug)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Bug.Add(bug);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.Features = Features(_context);
|
||||
ViewBag.Statuses = Statuses(default(BugStatus));
|
||||
return View(bug);
|
||||
}
|
||||
|
||||
// GET: Bug/Edit/5
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bug == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
ViewBag.Features = Features(_context);
|
||||
ViewBag.Statuses = Statuses(bug.Status);
|
||||
|
||||
return View(bug);
|
||||
}
|
||||
|
||||
// POST: Bug/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> Edit(Bug bug)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(bug);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(bug);
|
||||
}
|
||||
|
||||
// GET: Bug/Delete/5
|
||||
[ActionName("Delete")]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
if (bug == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(bug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// POST: Bug/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
_context.Bug.Remove(bug);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> DeleteAllLike(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
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, int prefixLen = 25)
|
||||
{
|
||||
Bug bug = await _context.Bug.SingleAsync(m => m.Id == id);
|
||||
var bugs = await _context.Bug.Where(b => b.Description.Substring(0, prefixLen) == bug.Description.Substring(0, prefixLen)).ToArrayAsync();
|
||||
foreach (var btd in bugs)
|
||||
_context.Bug.Remove(btd);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
136
src/Yavsc.Org/Controllers/Survey/FeatureController.cs
Normal file
136
src/Yavsc.Org/Controllers/Survey/FeatureController.cs
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Models;
|
||||
using Models.IT.Evolution;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
||||
public class FeatureController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly IStringLocalizer<BugController> _bugLocalizer;
|
||||
|
||||
IEnumerable<SelectListItem> Statuses(FeatureStatus ?status) =>
|
||||
_bugLocalizer.CreateSelectListItems(typeof(FeatureStatus), status);
|
||||
public FeatureController(ApplicationDbContext context, IStringLocalizer<BugController> bugLocalizer)
|
||||
{
|
||||
_context = context;
|
||||
_bugLocalizer = bugLocalizer;
|
||||
}
|
||||
|
||||
// GET: Feature
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Feature.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Feature/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Feature feature = await _context.Feature.SingleAsync(m => m.Id == id);
|
||||
if (feature == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(feature);
|
||||
}
|
||||
|
||||
// GET: Feature/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.FeatureStatus = Statuses(default(FeatureStatus));
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Feature/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Feature feature)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Feature.Add(feature);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.FeatureStatus = Statuses(default(FeatureStatus));
|
||||
return View(feature);
|
||||
}
|
||||
|
||||
// GET: Feature/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Feature feature = await _context.Feature.SingleAsync(m => m.Id == id);
|
||||
if (feature == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
var featureStatusEnumType = typeof(FeatureStatus);
|
||||
var fsstatuses = new List<SelectListItem>();
|
||||
foreach (var v in featureStatusEnumType.GetEnumValues())
|
||||
{
|
||||
fsstatuses.Add(new SelectListItem { Value = v.ToString(), Text = featureStatusEnumType.GetEnumName(v) });
|
||||
}
|
||||
ViewBag.Statuses = fsstatuses;
|
||||
return View(feature);
|
||||
}
|
||||
|
||||
// POST: Feature/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Feature feature)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(feature);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(feature);
|
||||
}
|
||||
|
||||
// GET: Feature/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Feature feature = await _context.Feature.SingleAsync(m => m.Id == id);
|
||||
if (feature == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(feature);
|
||||
}
|
||||
|
||||
// POST: Feature/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Feature feature = await _context.Feature.SingleAsync(m => m.Id == id);
|
||||
_context.Feature.Remove(feature);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/Yavsc.Org/Controllers/Survey/TestController.cs
Normal file
16
src/Yavsc.Org/Controllers/Survey/TestController.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class TestController: Controller
|
||||
{
|
||||
public IActionResult CalendarEventDateComponent()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public IActionResult MarkdownForms()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue