factorisation
This commit is contained in:
parent
f60584b0e4
commit
d14ee05a5d
3 changed files with 114 additions and 83 deletions
|
|
@ -5,69 +5,18 @@ using Microsoft.Data.Entity;
|
|||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Controllers.Generic;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize(Roles="Performer")]
|
||||
public class BrusherProfileController : Controller
|
||||
public class BrusherProfileController : SettingsController<BrusherProfile>
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public BrusherProfileController(ApplicationDbContext context)
|
||||
public BrusherProfileController(ApplicationDbContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: BrusherProfile
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var existing = await _context.BrusherProfile.SingleOrDefaultAsync(p=>p.UserId == User.GetUserId());
|
||||
return View(existing);
|
||||
}
|
||||
|
||||
// GET: BrusherProfile/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
id = User.GetUserId();
|
||||
}
|
||||
|
||||
BrusherProfile brusherProfile = await _context.BrusherProfile.SingleAsync(m => m.UserId == id);
|
||||
if (brusherProfile == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(brusherProfile);
|
||||
}
|
||||
|
||||
// GET: BrusherProfile/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// GET: BrusherProfile/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
id = User.GetUserId();
|
||||
}
|
||||
|
||||
BrusherProfile brusherProfile = await _context.BrusherProfile.SingleOrDefaultAsync(m => m.UserId == id);
|
||||
if (brusherProfile == null)
|
||||
{
|
||||
brusherProfile = new BrusherProfile { };
|
||||
}
|
||||
return View(brusherProfile);
|
||||
}
|
||||
|
||||
// POST: BrusherProfile/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(BrusherProfile brusherProfile)
|
||||
override public async Task<IActionResult> Edit(BrusherProfile brusherProfile)
|
||||
{
|
||||
if (string.IsNullOrEmpty(brusherProfile.UserId))
|
||||
{
|
||||
|
|
@ -89,28 +38,8 @@ namespace Yavsc.Controllers
|
|||
return View(brusherProfile);
|
||||
}
|
||||
|
||||
// GET: BrusherProfile/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
BrusherProfile brusherProfile = await _context.BrusherProfile.SingleAsync(m => m.UserId == id);
|
||||
if (brusherProfile == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(brusherProfile);
|
||||
}
|
||||
|
||||
// POST: BrusherProfile/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
override public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
BrusherProfile brusherProfile = await _context.BrusherProfile.SingleAsync(m => m.UserId == id);
|
||||
_context.BrusherProfile.Remove(brusherProfile);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue