User settings
This commit is contained in:
@ -59,7 +59,7 @@ namespace Yavsc.Controllers
|
||||
return NotFound();
|
||||
}
|
||||
bool hasConfigurableSettings = (userActivity.Does.SettingsClassName != null);
|
||||
var settings = await billing.GetPerformerSettingsAsync(activityCode,id);
|
||||
var settings = await billing.GetPerformersSettingsAsync(activityCode, id);
|
||||
ViewBag.ProfileType = Config.ProfileTypes.Single(t=>t.FullName==userActivity.Does.SettingsClassName);
|
||||
|
||||
var gift = new UserActivityViewModel {
|
||||
|
@ -9,6 +9,7 @@ namespace Yavsc.Controllers
|
||||
|
||||
public FormationSettingsController(ApplicationDbContext context) : base(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,26 +53,26 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
public ActionResult Profiles(string id)
|
||||
public async Task<ActionResult> Profiles(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
throw new NotImplementedException("No Activity code");
|
||||
}
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == id);
|
||||
var result = _context.ListPerformers(_billing, id);
|
||||
ViewBag.Activity = await _context.Activities.FirstOrDefaultAsync(a => a.Code == id);
|
||||
var result = await _context.ListPerformersAsync(_billing, id);
|
||||
return View(result);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
public ActionResult HairCut(string id)
|
||||
public async Task <ActionResult> HairCut(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
throw new NotImplementedException("No Activity code");
|
||||
}
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a => a.Code == id);
|
||||
var result = _context.ListPerformers(_billing, id);
|
||||
ViewBag.Activity = await _context.Activities.FirstOrDefaultAsync(a => a.Code == id);
|
||||
var result = await _context.ListPerformersAsync(_billing, id);
|
||||
return View(result);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace Yavsc.Controllers.Generic
|
||||
using Yavsc.Services;
|
||||
|
||||
[Authorize]
|
||||
public abstract class SettingsController<TSettings> : Controller where TSettings : class, ISpecializationSettings, new()
|
||||
public abstract class SettingsController<TSettings> : Controller where TSettings : class, IUserSettings, new()
|
||||
{
|
||||
protected ApplicationDbContext _context;
|
||||
DbSet<TSettings> dbSet=null;
|
||||
@ -21,11 +21,17 @@ namespace Yavsc.Controllers.Generic
|
||||
if (dbSet == null) {
|
||||
dbSet = (DbSet<TSettings>) BillingService.UserSettings.Single(s=>s.Name == typeof(TSettings).Name).GetValue(_context);
|
||||
}
|
||||
|
||||
|
||||
return dbSet;
|
||||
} }
|
||||
|
||||
virtual protected async Task<TSettings> GetSettingsAsync(
|
||||
string userId
|
||||
)
|
||||
{
|
||||
return await Settings.SingleOrDefaultAsync(p=>p.UserId == userId);
|
||||
}
|
||||
|
||||
|
||||
public SettingsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
@ -33,8 +39,7 @@ namespace Yavsc.Controllers.Generic
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var existing = await this.Settings.SingleOrDefaultAsync(p=>p.UserId == User.GetUserId());
|
||||
return View(existing);
|
||||
return View(await GetSettingsAsync(User.GetUserId()));
|
||||
}
|
||||
// GET: BrusherProfile/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
@ -44,7 +49,7 @@ namespace Yavsc.Controllers.Generic
|
||||
id = User.GetUserId();
|
||||
}
|
||||
|
||||
var profile = await Settings.SingleAsync(m => m.UserId == id);
|
||||
var profile = await GetSettingsAsync(id);
|
||||
if (profile == null)
|
||||
{
|
||||
return NotFound();
|
||||
@ -68,7 +73,7 @@ namespace Yavsc.Controllers.Generic
|
||||
id = User.GetUserId();
|
||||
}
|
||||
|
||||
TSettings setting = await Settings.SingleOrDefaultAsync(m => m.UserId == id);
|
||||
TSettings setting = await GetSettingsAsync(id);
|
||||
if (setting == null)
|
||||
{
|
||||
setting = new TSettings { };
|
||||
@ -87,13 +92,13 @@ namespace Yavsc.Controllers.Generic
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var brusherProfile = await Settings.SingleAsync(m => m.UserId == id);
|
||||
if (brusherProfile == null)
|
||||
var profile = await GetSettingsAsync(id);
|
||||
if (profile == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return View(brusherProfile);
|
||||
return View(profile);
|
||||
}
|
||||
|
||||
// POST: FormationSettings/Create
|
||||
@ -135,8 +140,8 @@ namespace Yavsc.Controllers.Generic
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
TSettings formationSettings = await Settings.SingleAsync(m => m.UserId == id);
|
||||
Settings.Remove(formationSettings);
|
||||
TSettings userSettings = await GetSettingsAsync(id);
|
||||
Settings.Remove(userSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
Reference in New Issue
Block a user