code cleanup
This commit is contained in:
parent
7b92745153
commit
ec2c405e28
4 changed files with 1 additions and 137 deletions
|
|
@ -1,120 +0,0 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Yavsc.Models;
|
|
||||||
using Yavsc.Models.Forms;
|
|
||||||
using Yavsc.Server.Helpers;
|
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
|
||||||
{
|
|
||||||
public class FormsController : Controller
|
|
||||||
{
|
|
||||||
private readonly ApplicationDbContext _context;
|
|
||||||
|
|
||||||
public FormsController(ApplicationDbContext context)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: Forms
|
|
||||||
public async Task<IActionResult> Index()
|
|
||||||
{
|
|
||||||
return View(await _context.Form.ToListAsync());
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: Forms/Details/5
|
|
||||||
public async Task<IActionResult> Details(string id)
|
|
||||||
{
|
|
||||||
if (id == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
|
||||||
if (form == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return View(form);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: Forms/Create
|
|
||||||
public IActionResult Create()
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST: Forms/Create
|
|
||||||
[HttpPost]
|
|
||||||
[ValidateAntiForgeryToken]
|
|
||||||
public async Task<IActionResult> Create(Form form)
|
|
||||||
{
|
|
||||||
if (ModelState.IsValid)
|
|
||||||
{
|
|
||||||
_context.Form.Add(form);
|
|
||||||
await _context.SaveChangesAsync(User.GetUserId());
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
}
|
|
||||||
return View(form);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: Forms/Edit/5
|
|
||||||
public async Task<IActionResult> Edit(string id)
|
|
||||||
{
|
|
||||||
if (id == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
|
||||||
if (form == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
return View(form);
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST: Forms/Edit/5
|
|
||||||
[HttpPost]
|
|
||||||
[ValidateAntiForgeryToken]
|
|
||||||
public async Task<IActionResult> Edit(Form form)
|
|
||||||
{
|
|
||||||
if (ModelState.IsValid)
|
|
||||||
{
|
|
||||||
_context.Update(form);
|
|
||||||
await _context.SaveChangesAsync(User.GetUserId());
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
}
|
|
||||||
return View(form);
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: Forms/Delete/5
|
|
||||||
[ActionName("Delete")]
|
|
||||||
public async Task<IActionResult> Delete(string id)
|
|
||||||
{
|
|
||||||
if (id == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
|
||||||
if (form == null)
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return View(form);
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST: Forms/Delete/5
|
|
||||||
[HttpPost, ActionName("Delete")]
|
|
||||||
[ValidateAntiForgeryToken]
|
|
||||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
|
||||||
{
|
|
||||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
|
||||||
_context.Form.Remove(form);
|
|
||||||
await _context.SaveChangesAsync(User.GetUserId());
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -13,7 +13,6 @@ namespace Yavsc.Models
|
||||||
using Blog;
|
using Blog;
|
||||||
using Chat;
|
using Chat;
|
||||||
using Drawing;
|
using Drawing;
|
||||||
using Forms;
|
|
||||||
using Haircut;
|
using Haircut;
|
||||||
using Identity;
|
using Identity;
|
||||||
using IT.Evolution;
|
using IT.Evolution;
|
||||||
|
|
@ -352,8 +351,6 @@ namespace Yavsc.Models
|
||||||
|
|
||||||
public DbSet<CommandForm> CommandForm { get; set; }
|
public DbSet<CommandForm> CommandForm { get; set; }
|
||||||
|
|
||||||
public DbSet<Form> Form { get; set; }
|
|
||||||
|
|
||||||
public DbSet<Ban> Ban { get; set; }
|
public DbSet<Ban> Ban { get; set; }
|
||||||
|
|
||||||
public DbSet<HairTaint> HairTaint { get; set; }
|
public DbSet<HairTaint> HairTaint { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Yavsc.Models.Forms
|
|
||||||
{
|
|
||||||
|
|
||||||
public class Form
|
|
||||||
{
|
|
||||||
[Key]
|
|
||||||
public string Id {get; set;}
|
|
||||||
public string Summary { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -31,7 +31,6 @@ namespace Yavsc.ViewModels.FrontOffice
|
||||||
WebSite = profile.WebSite;
|
WebSite = profile.WebSite;
|
||||||
Extra = profile.Activity.Where(a => a.DoesCode != activityCode).ToArray();
|
Extra = profile.Activity.Where(a => a.DoesCode != activityCode).ToArray();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue