refactoring

This commit is contained in:
Paul Schneider 2017-03-06 02:04:33 +01:00
commit 055eb14607
5 changed files with 56 additions and 162 deletions

View file

@ -1,7 +1,3 @@
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
using System.Security.Claims;
using Microsoft.Data.Entity;
using Yavsc.Models;
using Yavsc.Models.Haircut;
using Microsoft.AspNet.Authorization;
@ -16,35 +12,6 @@ namespace Yavsc.Controllers
public BrusherProfileController(ApplicationDbContext context) : base(context)
{
}
override public async Task<IActionResult> Edit(BrusherProfile brusherProfile)
{
if (string.IsNullOrEmpty(brusherProfile.UserId))
{
// a creation
brusherProfile.UserId = User.GetUserId();
if (ModelState.IsValid)
{
_context.BrusherProfile.Add(brusherProfile);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
}
else if (ModelState.IsValid)
{
_context.Update(brusherProfile);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(brusherProfile);
}
// POST: BrusherProfile/Delete/5
override public async Task<IActionResult> DeleteConfirmed(string id)
{
BrusherProfile brusherProfile = await _context.BrusherProfile.SingleAsync(m => m.UserId == id);
_context.BrusherProfile.Remove(brusherProfile);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
}
}