re-organisation
This commit is contained in:
@ -1,122 +1,122 @@
|
||||
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CircleController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CircleController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Circle
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Circle.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Circle/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Circle/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Circle circle)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Circle.Add(circle);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// POST: Circle/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Circle circle)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(circle);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// POST: Circle/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
_context.Circle.Remove(circle);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CircleController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CircleController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Circle
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Circle.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Circle/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Circle/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Circle circle)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Circle.Add(circle);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// POST: Circle/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Circle circle)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(circle);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// GET: Circle/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
if (circle == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circle);
|
||||
}
|
||||
|
||||
// POST: Circle/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Circle circle = await _context.Circle.SingleAsync(m => m.Id == id);
|
||||
_context.Circle.Remove(circle);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,135 +1,135 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CircleMembersController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CircleMembersController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: CircleMembers
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var applicationDbContext = _context.CircleMembers.Include(c => c.Circle).Include(c => c.Member)
|
||||
.Where(c=>c.Circle.OwnerId == uid);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: CircleMembers/Details/5
|
||||
public async Task<IActionResult> Details(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Circle)
|
||||
.FirstOrDefaultAsync(c=>c.CircleId == id);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMembers/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
ViewBag.CircleId = new SelectList(_context.Circle.Where(c=>c.OwnerId == uid), "Id", "Name");
|
||||
ViewBag.MemberId = new SelectList(_context.Users, "Id", "UserName");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: CircleMembers/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(CircleMember circleMember)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var circle = _context.Circle.SingleOrDefault(c=>c.OwnerId == uid && c.Id == circleMember.CircleId);
|
||||
if (circle==null)
|
||||
return new BadRequestResult();
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.CircleMembers.Add(circleMember);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["CircleId"] = new SelectList(_context.Circle, "Id", "Name", circleMember.CircleId);
|
||||
ViewData["MemberId"] = new SelectList(_context.Users, "Id", "UserName", circleMember.MemberId);
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMembers/Edit/5
|
||||
public async Task<IActionResult> Edit(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Member)
|
||||
.SingleOrDefaultAsync(m => m.CircleId == id && m.MemberId == uid);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// POST: CircleMembers/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(CircleMember circleMember)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(circleMember);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["CircleId"] = new SelectList(_context.Circle, "Id", "Circle", circleMember.CircleId);
|
||||
ViewData["MemberId"] = new SelectList(_context.Users, "Id", "Member", circleMember.MemberId);
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMembers/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Circle)
|
||||
.Include(m=>m.Member)
|
||||
.SingleOrDefaultAsync(m => m.CircleId == id && m.MemberId == uid);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// POST: CircleMembers/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.CircleId == id);
|
||||
_context.CircleMembers.Remove(circleMember);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CircleMembersController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CircleMembersController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: CircleMembers
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var applicationDbContext = _context.CircleMembers.Include(c => c.Circle).Include(c => c.Member)
|
||||
.Where(c=>c.Circle.OwnerId == uid);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: CircleMembers/Details/5
|
||||
public async Task<IActionResult> Details(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Circle)
|
||||
.FirstOrDefaultAsync(c=>c.CircleId == id);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMembers/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
ViewBag.CircleId = new SelectList(_context.Circle.Where(c=>c.OwnerId == uid), "Id", "Name");
|
||||
ViewBag.MemberId = new SelectList(_context.Users, "Id", "UserName");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: CircleMembers/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(CircleMember circleMember)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var circle = _context.Circle.SingleOrDefault(c=>c.OwnerId == uid && c.Id == circleMember.CircleId);
|
||||
if (circle==null)
|
||||
return new BadRequestResult();
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.CircleMembers.Add(circleMember);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["CircleId"] = new SelectList(_context.Circle, "Id", "Name", circleMember.CircleId);
|
||||
ViewData["MemberId"] = new SelectList(_context.Users, "Id", "UserName", circleMember.MemberId);
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMembers/Edit/5
|
||||
public async Task<IActionResult> Edit(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Member)
|
||||
.SingleOrDefaultAsync(m => m.CircleId == id && m.MemberId == uid);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// POST: CircleMembers/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(CircleMember circleMember)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(circleMember);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["CircleId"] = new SelectList(_context.Circle, "Id", "Circle", circleMember.CircleId);
|
||||
ViewData["MemberId"] = new SelectList(_context.Users, "Id", "Member", circleMember.MemberId);
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// GET: CircleMembers/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
|
||||
CircleMember circleMember = await _context.CircleMembers
|
||||
.Include(m=>m.Circle)
|
||||
.Include(m=>m.Member)
|
||||
.SingleOrDefaultAsync(m => m.CircleId == id && m.MemberId == uid);
|
||||
if (circleMember == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(circleMember);
|
||||
}
|
||||
|
||||
// POST: CircleMembers/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CircleMember circleMember = await _context.CircleMembers.SingleAsync(m => m.CircleId == id);
|
||||
_context.CircleMembers.Remove(circleMember);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,139 +1,139 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using System.Collections.Generic;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Auth;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class ClientController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public ClientController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Client
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Applications.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Client/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(client);
|
||||
}
|
||||
|
||||
// GET: Client/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
SetAppTypesInputValues();
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Client/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Client client)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
client.Id = Guid.NewGuid().ToString();
|
||||
_context.Applications.Add(client);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
SetAppTypesInputValues();
|
||||
return View(client);
|
||||
}
|
||||
private void SetAppTypesInputValues()
|
||||
{
|
||||
IEnumerable<SelectListItem> types = new SelectListItem[] {
|
||||
new SelectListItem {
|
||||
Text = ApplicationTypes.JavaScript.ToString(),
|
||||
Value = ((int) ApplicationTypes.JavaScript).ToString() },
|
||||
new SelectListItem {
|
||||
Text = ApplicationTypes.NativeConfidential.ToString(),
|
||||
Value = ((int) ApplicationTypes.NativeConfidential).ToString()
|
||||
}
|
||||
};
|
||||
ViewData["Type"] = types;
|
||||
}
|
||||
// GET: Client/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
SetAppTypesInputValues();
|
||||
return View(client);
|
||||
}
|
||||
|
||||
// POST: Client/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Client client)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(client);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(client);
|
||||
}
|
||||
|
||||
// GET: Client/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(client);
|
||||
}
|
||||
|
||||
// POST: Client/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
_context.Applications.Remove(client);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using System.Collections.Generic;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Auth;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class ClientController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public ClientController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Client
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Applications.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Client/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(client);
|
||||
}
|
||||
|
||||
// GET: Client/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
SetAppTypesInputValues();
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Client/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Client client)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
client.Id = Guid.NewGuid().ToString();
|
||||
_context.Applications.Add(client);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
SetAppTypesInputValues();
|
||||
return View(client);
|
||||
}
|
||||
private void SetAppTypesInputValues()
|
||||
{
|
||||
IEnumerable<SelectListItem> types = new SelectListItem[] {
|
||||
new SelectListItem {
|
||||
Text = ApplicationTypes.JavaScript.ToString(),
|
||||
Value = ((int) ApplicationTypes.JavaScript).ToString() },
|
||||
new SelectListItem {
|
||||
Text = ApplicationTypes.NativeConfidential.ToString(),
|
||||
Value = ((int) ApplicationTypes.NativeConfidential).ToString()
|
||||
}
|
||||
};
|
||||
ViewData["Type"] = types;
|
||||
}
|
||||
// GET: Client/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
SetAppTypesInputValues();
|
||||
return View(client);
|
||||
}
|
||||
|
||||
// POST: Client/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Client client)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(client);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(client);
|
||||
}
|
||||
|
||||
// GET: Client/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
if (client == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(client);
|
||||
}
|
||||
|
||||
// POST: Client/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
Client client = await _context.Applications.SingleAsync(m => m.Id == id);
|
||||
_context.Applications.Remove(client);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,132 +1,132 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CoWorkingController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CoWorkingController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: CoWorking
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var applicationDbContext = _context.WorkflowProviders.Include(c => c.Performer).Include(c => c.WorkingFor);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: CoWorking/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// GET: CoWorking/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.PerformerId = _context.Performers.Select( p=> new SelectListItem { Value = p.PerformerId, Text = p.Performer.UserName});
|
||||
ViewBag.WorkingForId = new SelectList(_context.Users, "Id", "UserName");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: CoWorking/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(CoWorking coWorking)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.WorkflowProviders.Add(coWorking);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
|
||||
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// GET: CoWorking/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
|
||||
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// POST: CoWorking/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(CoWorking coWorking)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(coWorking);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
|
||||
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// GET: CoWorking/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// POST: CoWorking/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
|
||||
_context.WorkflowProviders.Remove(coWorking);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CoWorkingController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CoWorkingController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: CoWorking
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var applicationDbContext = _context.WorkflowProviders.Include(c => c.Performer).Include(c => c.WorkingFor);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: CoWorking/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// GET: CoWorking/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.PerformerId = _context.Performers.Select( p=> new SelectListItem { Value = p.PerformerId, Text = p.Performer.UserName});
|
||||
ViewBag.WorkingForId = new SelectList(_context.Users, "Id", "UserName");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: CoWorking/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(CoWorking coWorking)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.WorkflowProviders.Add(coWorking);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
|
||||
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// GET: CoWorking/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
|
||||
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// POST: CoWorking/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(CoWorking coWorking)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(coWorking);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["PerformerId"] = new SelectList(_context.Performers, "PerformerId", "Performer", coWorking.PerformerId);
|
||||
ViewData["WorkingForId"] = new SelectList(_context.Users, "Id", "WorkingFor", coWorking.WorkingForId);
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// GET: CoWorking/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
|
||||
if (coWorking == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(coWorking);
|
||||
}
|
||||
|
||||
// POST: CoWorking/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CoWorking coWorking = await _context.WorkflowProviders.SingleAsync(m => m.Id == id);
|
||||
_context.WorkflowProviders.Remove(coWorking);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,262 +1,262 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Helpers;
|
||||
using Models;
|
||||
using Models.Google.Messaging;
|
||||
using Models.Relationship;
|
||||
using Models.Workflow;
|
||||
using Services;
|
||||
|
||||
public class CommandController : Controller
|
||||
{
|
||||
protected UserManager<ApplicationUser> _userManager;
|
||||
protected ApplicationDbContext _context;
|
||||
protected GoogleAuthSettings _googleSettings;
|
||||
protected IGoogleCloudMessageSender _GCMSender;
|
||||
protected IEmailSender _emailSender;
|
||||
protected IStringLocalizer _localizer;
|
||||
protected SiteSettings _siteSettings;
|
||||
protected SmtpSettings _smtpSettings;
|
||||
|
||||
protected ICalendarManager _calendarManager;
|
||||
|
||||
protected readonly ILogger _logger;
|
||||
public CommandController(ApplicationDbContext context, IOptions<GoogleAuthSettings> googleSettings,
|
||||
IGoogleCloudMessageSender GCMSender,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ICalendarManager calendarManager,
|
||||
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
|
||||
IEmailSender emailSender,
|
||||
IOptions<SmtpSettings> smtpSettings,
|
||||
IOptions<SiteSettings> siteSettings,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
_context = context;
|
||||
_GCMSender = GCMSender;
|
||||
_emailSender = emailSender;
|
||||
_googleSettings = googleSettings.Value;
|
||||
_userManager = userManager;
|
||||
_smtpSettings = smtpSettings.Value;
|
||||
_siteSettings = siteSettings.Value;
|
||||
_calendarManager = calendarManager;
|
||||
_localizer = localizer;
|
||||
_logger = loggerFactory.CreateLogger<CommandController>();
|
||||
}
|
||||
|
||||
// GET: Command
|
||||
[Authorize]
|
||||
public virtual async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
return View(await _context.RdvQueries
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.PerformerProfile)
|
||||
.Include(x => x.PerformerProfile.Performer)
|
||||
.Include(x => x.Location)
|
||||
.Where(x=> x.ClientId == uid || x.PerformerId == uid)
|
||||
.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Command/Details/5
|
||||
public virtual async Task<IActionResult> Details(long id)
|
||||
{
|
||||
RdvQuery command = await _context.RdvQueries
|
||||
.Include(x => x.Location)
|
||||
.Include(x => x.PerformerProfile)
|
||||
.SingleAsync(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gives a view on
|
||||
/// Creating a command for a specified performer
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult Create(string proId, string activityCode, string billingCode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(proId))
|
||||
throw new InvalidOperationException(
|
||||
"This method needs a performer id (from parameter proId)"
|
||||
);
|
||||
if (string.IsNullOrWhiteSpace(activityCode))
|
||||
throw new InvalidOperationException(
|
||||
"This method needs an activity code"
|
||||
);
|
||||
var pro = _context.Performers.Include(
|
||||
x => x.Performer).FirstOrDefault(
|
||||
x => x.PerformerId == proId
|
||||
);
|
||||
if (pro == null)
|
||||
return HttpNotFound();
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == activityCode);
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
var userid = User.GetUserId();
|
||||
var user = _userManager.FindByIdAsync(userid).Result;
|
||||
return View("Create",new RdvQuery(activityCode,new Location(),DateTime.Now.AddHours(4))
|
||||
{
|
||||
PerformerProfile = pro,
|
||||
PerformerId = pro.PerformerId,
|
||||
ClientId = userid,
|
||||
Client = user,
|
||||
ActivityCode = activityCode
|
||||
});
|
||||
}
|
||||
|
||||
// POST: Command/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(RdvQuery command)
|
||||
{
|
||||
// TODO validate BillingCode value
|
||||
var uid = User.GetUserId();
|
||||
var prid = command.PerformerId;
|
||||
if (string.IsNullOrWhiteSpace(uid)
|
||||
|| string.IsNullOrWhiteSpace(prid))
|
||||
throw new InvalidOperationException(
|
||||
"This method needs a PerformerId"
|
||||
);
|
||||
var pro = _context.Performers.Include(
|
||||
u => u.Performer
|
||||
).Include(u => u.Performer.Devices)
|
||||
.FirstOrDefault(
|
||||
x => x.PerformerId == command.PerformerId
|
||||
);
|
||||
var user = await _userManager.FindByIdAsync(uid);
|
||||
command.Client = user;
|
||||
command.ClientId = uid;
|
||||
command.PerformerProfile = pro;
|
||||
// FIXME Why!!
|
||||
// ModelState.ClearValidationState("PerformerProfile.Avatar");
|
||||
// ModelState.ClearValidationState("Client.Avatar");
|
||||
// ModelState.ClearValidationState("ClientId");
|
||||
ModelState.MarkFieldSkipped("ClientId");
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address
|
||||
&& x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude );
|
||||
|
||||
if (existingLocation!=null) {
|
||||
command.Location=existingLocation;
|
||||
}
|
||||
else _context.Attach<Location>(command.Location);
|
||||
_context.RdvQueries.Add(command, GraphBehavior.IncludeDependents);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
||||
var yaev = command.CreateEvent(_localizer, "NewCommand");
|
||||
|
||||
MessageWithPayloadResponse grep = null;
|
||||
|
||||
if (pro.AcceptNotifications
|
||||
&& pro.AcceptPublicContact)
|
||||
{
|
||||
if (pro.Performer.Devices.Count > 0) {
|
||||
var regids = command.PerformerProfile.Performer
|
||||
.Devices.Select(d => d.GCMRegistrationId);
|
||||
grep = await _GCMSender.NotifyBookQueryAsync(regids,yaev);
|
||||
}
|
||||
|
||||
// TODO setup a profile choice to allow notifications
|
||||
// both on mailbox and mobile
|
||||
// if (grep==null || grep.success<=0 || grep.failure>0)
|
||||
ViewBag.GooglePayload=grep;
|
||||
|
||||
ViewBag.EmailSent = await _emailSender.SendEmailAsync(
|
||||
command.PerformerProfile.Performer.UserName,
|
||||
command.PerformerProfile.Performer.Email,
|
||||
$"{command.Client.UserName} (un client) vous demande un rendez-vous",
|
||||
$"{yaev.CreateBody()}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
|
||||
);
|
||||
}
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
return View("CommandConfirmation",command);
|
||||
}
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
return View(command);
|
||||
}
|
||||
|
||||
// GET: Command/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(command);
|
||||
}
|
||||
|
||||
// POST: Command/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(RdvQuery command)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(command);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(command);
|
||||
}
|
||||
|
||||
// GET: Command/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(command);
|
||||
}
|
||||
|
||||
// POST: Command/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
|
||||
_context.RdvQueries.Remove(command);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
public IActionResult CGV()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Helpers;
|
||||
using Models;
|
||||
using Models.Google.Messaging;
|
||||
using Models.Relationship;
|
||||
using Models.Workflow;
|
||||
using Services;
|
||||
|
||||
public class CommandController : Controller
|
||||
{
|
||||
protected UserManager<ApplicationUser> _userManager;
|
||||
protected ApplicationDbContext _context;
|
||||
protected GoogleAuthSettings _googleSettings;
|
||||
protected IGoogleCloudMessageSender _GCMSender;
|
||||
protected IEmailSender _emailSender;
|
||||
protected IStringLocalizer _localizer;
|
||||
protected SiteSettings _siteSettings;
|
||||
protected SmtpSettings _smtpSettings;
|
||||
|
||||
protected ICalendarManager _calendarManager;
|
||||
|
||||
protected readonly ILogger _logger;
|
||||
public CommandController(ApplicationDbContext context, IOptions<GoogleAuthSettings> googleSettings,
|
||||
IGoogleCloudMessageSender GCMSender,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ICalendarManager calendarManager,
|
||||
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
|
||||
IEmailSender emailSender,
|
||||
IOptions<SmtpSettings> smtpSettings,
|
||||
IOptions<SiteSettings> siteSettings,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
_context = context;
|
||||
_GCMSender = GCMSender;
|
||||
_emailSender = emailSender;
|
||||
_googleSettings = googleSettings.Value;
|
||||
_userManager = userManager;
|
||||
_smtpSettings = smtpSettings.Value;
|
||||
_siteSettings = siteSettings.Value;
|
||||
_calendarManager = calendarManager;
|
||||
_localizer = localizer;
|
||||
_logger = loggerFactory.CreateLogger<CommandController>();
|
||||
}
|
||||
|
||||
// GET: Command
|
||||
[Authorize]
|
||||
public virtual async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
return View(await _context.RdvQueries
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.PerformerProfile)
|
||||
.Include(x => x.PerformerProfile.Performer)
|
||||
.Include(x => x.Location)
|
||||
.Where(x=> x.ClientId == uid || x.PerformerId == uid)
|
||||
.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Command/Details/5
|
||||
public virtual async Task<IActionResult> Details(long id)
|
||||
{
|
||||
RdvQuery command = await _context.RdvQueries
|
||||
.Include(x => x.Location)
|
||||
.Include(x => x.PerformerProfile)
|
||||
.SingleAsync(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(command);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gives a view on
|
||||
/// Creating a command for a specified performer
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult Create(string proId, string activityCode, string billingCode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(proId))
|
||||
throw new InvalidOperationException(
|
||||
"This method needs a performer id (from parameter proId)"
|
||||
);
|
||||
if (string.IsNullOrWhiteSpace(activityCode))
|
||||
throw new InvalidOperationException(
|
||||
"This method needs an activity code"
|
||||
);
|
||||
var pro = _context.Performers.Include(
|
||||
x => x.Performer).FirstOrDefault(
|
||||
x => x.PerformerId == proId
|
||||
);
|
||||
if (pro == null)
|
||||
return HttpNotFound();
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == activityCode);
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
var userid = User.GetUserId();
|
||||
var user = _userManager.FindByIdAsync(userid).Result;
|
||||
return View("Create",new RdvQuery(activityCode,new Location(),DateTime.Now.AddHours(4))
|
||||
{
|
||||
PerformerProfile = pro,
|
||||
PerformerId = pro.PerformerId,
|
||||
ClientId = userid,
|
||||
Client = user,
|
||||
ActivityCode = activityCode
|
||||
});
|
||||
}
|
||||
|
||||
// POST: Command/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(RdvQuery command)
|
||||
{
|
||||
// TODO validate BillingCode value
|
||||
var uid = User.GetUserId();
|
||||
var prid = command.PerformerId;
|
||||
if (string.IsNullOrWhiteSpace(uid)
|
||||
|| string.IsNullOrWhiteSpace(prid))
|
||||
throw new InvalidOperationException(
|
||||
"This method needs a PerformerId"
|
||||
);
|
||||
var pro = _context.Performers.Include(
|
||||
u => u.Performer
|
||||
).Include(u => u.Performer.Devices)
|
||||
.FirstOrDefault(
|
||||
x => x.PerformerId == command.PerformerId
|
||||
);
|
||||
var user = await _userManager.FindByIdAsync(uid);
|
||||
command.Client = user;
|
||||
command.ClientId = uid;
|
||||
command.PerformerProfile = pro;
|
||||
// FIXME Why!!
|
||||
// ModelState.ClearValidationState("PerformerProfile.Avatar");
|
||||
// ModelState.ClearValidationState("Client.Avatar");
|
||||
// ModelState.ClearValidationState("ClientId");
|
||||
ModelState.MarkFieldSkipped("ClientId");
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var existingLocation = _context.Locations.FirstOrDefault( x=>x.Address == command.Location.Address
|
||||
&& x.Longitude == command.Location.Longitude && x.Latitude == command.Location.Latitude );
|
||||
|
||||
if (existingLocation!=null) {
|
||||
command.Location=existingLocation;
|
||||
}
|
||||
else _context.Attach<Location>(command.Location);
|
||||
_context.RdvQueries.Add(command, GraphBehavior.IncludeDependents);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
||||
var yaev = command.CreateEvent(_localizer, "NewCommand");
|
||||
|
||||
MessageWithPayloadResponse grep = null;
|
||||
|
||||
if (pro.AcceptNotifications
|
||||
&& pro.AcceptPublicContact)
|
||||
{
|
||||
if (pro.Performer.Devices.Count > 0) {
|
||||
var regids = command.PerformerProfile.Performer
|
||||
.Devices.Select(d => d.GCMRegistrationId);
|
||||
grep = await _GCMSender.NotifyBookQueryAsync(regids,yaev);
|
||||
}
|
||||
|
||||
// TODO setup a profile choice to allow notifications
|
||||
// both on mailbox and mobile
|
||||
// if (grep==null || grep.success<=0 || grep.failure>0)
|
||||
ViewBag.GooglePayload=grep;
|
||||
|
||||
ViewBag.EmailSent = await _emailSender.SendEmailAsync(
|
||||
command.PerformerProfile.Performer.UserName,
|
||||
command.PerformerProfile.Performer.Email,
|
||||
$"{command.Client.UserName} (un client) vous demande un rendez-vous",
|
||||
$"{yaev.CreateBody()}\r\n-- \r\n{yaev.Previsional}\r\n{yaev.EventDate}\r\n"
|
||||
);
|
||||
}
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
return View("CommandConfirmation",command);
|
||||
}
|
||||
ViewBag.Activity = _context.Activities.FirstOrDefault(a=>a.Code == command.ActivityCode);
|
||||
ViewBag.GoogleSettings = _googleSettings;
|
||||
return View(command);
|
||||
}
|
||||
|
||||
// GET: Command/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(command);
|
||||
}
|
||||
|
||||
// POST: Command/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(RdvQuery command)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(command);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(command);
|
||||
}
|
||||
|
||||
// GET: Command/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
|
||||
if (command == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(command);
|
||||
}
|
||||
|
||||
// POST: Command/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
RdvQuery command = _context.RdvQueries.Single(m => m.Id == id);
|
||||
_context.RdvQueries.Remove(command);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
public IActionResult CGV()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,131 +1,131 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CommandFormsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CommandFormsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: CommandForms
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var applicationDbContext = _context.CommandForm.Include(c => c.Context);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: CommandForms/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// GET: CommandForms/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
SetViewBag();
|
||||
return View();
|
||||
}
|
||||
private void SetViewBag(CommandForm commandForm=null) {
|
||||
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode);
|
||||
ViewBag.ActionName = Startup.Forms.Select( c => new SelectListItem { Value = c, Text = c, Selected = (commandForm?.ActionName == c) } );
|
||||
}
|
||||
// POST: CommandForms/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(CommandForm commandForm)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.CommandForm.Add(commandForm);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
SetViewBag(commandForm);
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// GET: CommandForms/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
SetViewBag(commandForm);
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// POST: CommandForms/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(CommandForm commandForm)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(commandForm);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
SetViewBag(commandForm);
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// GET: CommandForms/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// POST: CommandForms/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
_context.CommandForm.Remove(commandForm);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class CommandFormsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public CommandFormsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: CommandForms
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var applicationDbContext = _context.CommandForm.Include(c => c.Context);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: CommandForms/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// GET: CommandForms/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
SetViewBag();
|
||||
return View();
|
||||
}
|
||||
private void SetViewBag(CommandForm commandForm=null) {
|
||||
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name", commandForm?.ActivityCode);
|
||||
ViewBag.ActionName = Startup.Forms.Select( c => new SelectListItem { Value = c, Text = c, Selected = (commandForm?.ActionName == c) } );
|
||||
}
|
||||
// POST: CommandForms/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(CommandForm commandForm)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.CommandForm.Add(commandForm);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
SetViewBag(commandForm);
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// GET: CommandForms/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
SetViewBag(commandForm);
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// POST: CommandForms/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(CommandForm commandForm)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(commandForm);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
SetViewBag(commandForm);
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// GET: CommandForms/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
if (commandForm == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// POST: CommandForms/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
_context.CommandForm.Remove(commandForm);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +1,120 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class DjSettingsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public DjSettingsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: DjSettings
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.DjSettings.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: DjSettings/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// GET: DjSettings/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: DjSettings/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(DjSettings djSettings)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.DjSettings.Add(djSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// GET: DjSettings/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// POST: DjSettings/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(DjSettings djSettings)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(djSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// GET: DjSettings/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// POST: DjSettings/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
_context.DjSettings.Remove(djSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class DjSettingsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public DjSettingsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: DjSettings
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.DjSettings.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: DjSettings/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// GET: DjSettings/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: DjSettings/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(DjSettings djSettings)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.DjSettings.Add(djSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// GET: DjSettings/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// POST: DjSettings/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(DjSettings djSettings)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(djSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// GET: DjSettings/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
if (djSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(djSettings);
|
||||
}
|
||||
|
||||
// POST: DjSettings/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
DjSettings djSettings = await _context.DjSettings.SingleAsync(m => m.UserId == id);
|
||||
_context.DjSettings.Remove(djSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,189 +1,189 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Models;
|
||||
using Models.Workflow;
|
||||
using Yavsc.ViewModels.Workflow;
|
||||
using Yavsc.Services;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[Authorize]
|
||||
public class DoController : Controller
|
||||
{
|
||||
private ApplicationDbContext dbContext;
|
||||
ILogger logger;
|
||||
IBillingService billing;
|
||||
public DoController(
|
||||
ApplicationDbContext context,
|
||||
IBillingService billing,
|
||||
ILogger<DoController> logger)
|
||||
{
|
||||
dbContext = context;
|
||||
this.billing = billing;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: /Do/Index
|
||||
[HttpGet]
|
||||
public IActionResult Index(string id)
|
||||
{
|
||||
if (id == null)
|
||||
id = User.GetUserId();
|
||||
|
||||
var userActivities = dbContext.UserActivities.Include(u => u.Does)
|
||||
.Include(u => u.User).Where(u=> u.UserId == id)
|
||||
.OrderByDescending(u => u.Weight);
|
||||
return View(userActivities.ToList());
|
||||
}
|
||||
|
||||
// GET: Do/Details/5
|
||||
public async Task<IActionResult> Details(string id, string activityCode)
|
||||
{
|
||||
|
||||
if (id == null || activityCode == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Include(m=>m.Does)
|
||||
.Include(m=>m.User).Single(m => m.DoesCode == activityCode && m.UserId == id);
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
bool hasConfigurableSettings = (userActivity.Does.SettingsClassName != null);
|
||||
var settings = await billing.GetPerformerSettingsAsync(activityCode,id);
|
||||
ViewBag.ProfileType = Startup.ProfileTypes.Single(t=>t.FullName==userActivity.Does.SettingsClassName);
|
||||
|
||||
var gift = new UserActivityViewModel {
|
||||
Declaration = userActivity,
|
||||
Settings = settings,
|
||||
NeedsSettings = hasConfigurableSettings
|
||||
};
|
||||
logger.LogInformation(JsonConvert.SerializeObject(gift.Settings));
|
||||
return View (gift);
|
||||
}
|
||||
|
||||
// GET: Do/Create
|
||||
[ActionName("Create"),Authorize]
|
||||
public IActionResult Create(string userId)
|
||||
{
|
||||
if (userId==null)
|
||||
userId = User.GetUserId();
|
||||
var model = new UserActivity { UserId = userId };
|
||||
ViewBag.DoesCode = new SelectList(dbContext.Activities, "Code", "Name");
|
||||
//ViewData["UserId"] = userId;
|
||||
ViewBag.UserId = new SelectList(dbContext.Performers.Include(p=>p.Performer), "PerformerId", "Performer", userId);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// POST: Do/Create
|
||||
[HttpPost(),ActionName("Create"),Authorize]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(UserActivity userActivity)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (uid != userActivity.UserId)
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
if (userActivity.UserId == null) userActivity.UserId = uid;
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
dbContext.UserActivities.Add(userActivity);
|
||||
dbContext.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.DoesCode = new SelectList(dbContext.Activities, "Code", "Name", userActivity.DoesCode);
|
||||
ViewBag.UserId = new SelectList(dbContext.Performers.Include(p=>p.Performer), "PerformerId", "User", userActivity.UserId);
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// GET: Do/Edit/5
|
||||
[Authorize]
|
||||
public IActionResult Edit(string id, string activityCode)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Include(
|
||||
u=>u.Does
|
||||
).Include(
|
||||
u=>u.User
|
||||
).Single(m => m.DoesCode == activityCode && m.UserId == id);
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewData["DoesCode"] = new SelectList(dbContext.Activities, "Code", "Does", userActivity.DoesCode);
|
||||
ViewData["UserId"] = new SelectList(dbContext.Performers, "PerformerId", "User", userActivity.UserId);
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// POST: Do/Edit/5
|
||||
[HttpPost,Authorize]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(UserActivity userActivity)
|
||||
{
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (User.GetUserId() != userActivity.UserId)
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
dbContext.Update(userActivity);
|
||||
dbContext.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["DoesCode"] = new SelectList(dbContext.Activities, "Code", "Does", userActivity.DoesCode);
|
||||
ViewData["UserId"] = new SelectList(dbContext.Performers, "PerformerId", "User", userActivity.UserId);
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// GET: Do/Delete/5
|
||||
[ActionName("Delete"),Authorize]
|
||||
public IActionResult Delete(string id, string activityCode)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Single(m => m.UserId == id && m.DoesCode == activityCode);
|
||||
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (User.GetUserId() != userActivity.UserId)
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// POST: Do/Delete/5
|
||||
[HttpPost, ActionName("Delete"),Authorize]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(UserActivity userActivity)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return new BadRequestObjectResult(ModelState);
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (User.GetUserId() != userActivity.UserId) {
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
dbContext.UserActivities.Remove(userActivity);
|
||||
dbContext.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Models;
|
||||
using Models.Workflow;
|
||||
using Yavsc.ViewModels.Workflow;
|
||||
using Yavsc.Services;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[Authorize]
|
||||
public class DoController : Controller
|
||||
{
|
||||
private ApplicationDbContext dbContext;
|
||||
ILogger logger;
|
||||
IBillingService billing;
|
||||
public DoController(
|
||||
ApplicationDbContext context,
|
||||
IBillingService billing,
|
||||
ILogger<DoController> logger)
|
||||
{
|
||||
dbContext = context;
|
||||
this.billing = billing;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// GET: /Do/Index
|
||||
[HttpGet]
|
||||
public IActionResult Index(string id)
|
||||
{
|
||||
if (id == null)
|
||||
id = User.GetUserId();
|
||||
|
||||
var userActivities = dbContext.UserActivities.Include(u => u.Does)
|
||||
.Include(u => u.User).Where(u=> u.UserId == id)
|
||||
.OrderByDescending(u => u.Weight);
|
||||
return View(userActivities.ToList());
|
||||
}
|
||||
|
||||
// GET: Do/Details/5
|
||||
public async Task<IActionResult> Details(string id, string activityCode)
|
||||
{
|
||||
|
||||
if (id == null || activityCode == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Include(m=>m.Does)
|
||||
.Include(m=>m.User).Single(m => m.DoesCode == activityCode && m.UserId == id);
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
bool hasConfigurableSettings = (userActivity.Does.SettingsClassName != null);
|
||||
var settings = await billing.GetPerformerSettingsAsync(activityCode,id);
|
||||
ViewBag.ProfileType = Startup.ProfileTypes.Single(t=>t.FullName==userActivity.Does.SettingsClassName);
|
||||
|
||||
var gift = new UserActivityViewModel {
|
||||
Declaration = userActivity,
|
||||
Settings = settings,
|
||||
NeedsSettings = hasConfigurableSettings
|
||||
};
|
||||
logger.LogInformation(JsonConvert.SerializeObject(gift.Settings));
|
||||
return View (gift);
|
||||
}
|
||||
|
||||
// GET: Do/Create
|
||||
[ActionName("Create"),Authorize]
|
||||
public IActionResult Create(string userId)
|
||||
{
|
||||
if (userId==null)
|
||||
userId = User.GetUserId();
|
||||
var model = new UserActivity { UserId = userId };
|
||||
ViewBag.DoesCode = new SelectList(dbContext.Activities, "Code", "Name");
|
||||
//ViewData["UserId"] = userId;
|
||||
ViewBag.UserId = new SelectList(dbContext.Performers.Include(p=>p.Performer), "PerformerId", "Performer", userId);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// POST: Do/Create
|
||||
[HttpPost(),ActionName("Create"),Authorize]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(UserActivity userActivity)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (uid != userActivity.UserId)
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
if (userActivity.UserId == null) userActivity.UserId = uid;
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
dbContext.UserActivities.Add(userActivity);
|
||||
dbContext.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.DoesCode = new SelectList(dbContext.Activities, "Code", "Name", userActivity.DoesCode);
|
||||
ViewBag.UserId = new SelectList(dbContext.Performers.Include(p=>p.Performer), "PerformerId", "User", userActivity.UserId);
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// GET: Do/Edit/5
|
||||
[Authorize]
|
||||
public IActionResult Edit(string id, string activityCode)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Include(
|
||||
u=>u.Does
|
||||
).Include(
|
||||
u=>u.User
|
||||
).Single(m => m.DoesCode == activityCode && m.UserId == id);
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewData["DoesCode"] = new SelectList(dbContext.Activities, "Code", "Does", userActivity.DoesCode);
|
||||
ViewData["UserId"] = new SelectList(dbContext.Performers, "PerformerId", "User", userActivity.UserId);
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// POST: Do/Edit/5
|
||||
[HttpPost,Authorize]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(UserActivity userActivity)
|
||||
{
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (User.GetUserId() != userActivity.UserId)
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
dbContext.Update(userActivity);
|
||||
dbContext.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["DoesCode"] = new SelectList(dbContext.Activities, "Code", "Does", userActivity.DoesCode);
|
||||
ViewData["UserId"] = new SelectList(dbContext.Performers, "PerformerId", "User", userActivity.UserId);
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// GET: Do/Delete/5
|
||||
[ActionName("Delete"),Authorize]
|
||||
public IActionResult Delete(string id, string activityCode)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
UserActivity userActivity = dbContext.UserActivities.Single(m => m.UserId == id && m.DoesCode == activityCode);
|
||||
|
||||
if (userActivity == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (User.GetUserId() != userActivity.UserId)
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
return View(userActivity);
|
||||
}
|
||||
|
||||
// POST: Do/Delete/5
|
||||
[HttpPost, ActionName("Delete"),Authorize]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(UserActivity userActivity)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return new BadRequestObjectResult(ModelState);
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (User.GetUserId() != userActivity.UserId) {
|
||||
ModelState.AddModelError("User","You're not admin.");
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
dbContext.UserActivities.Remove(userActivity);
|
||||
dbContext.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,220 +1,220 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Helpers;
|
||||
using Models;
|
||||
using Models.Billing;
|
||||
using Models.Workflow;
|
||||
using ViewModels.Auth;
|
||||
using Yavsc.Abstract.FileSystem;
|
||||
|
||||
[Authorize]
|
||||
public class EstimateController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
private SiteSettings _site;
|
||||
|
||||
IAuthorizationService authorizationService;
|
||||
|
||||
public EstimateController(ApplicationDbContext context, IAuthorizationService authorizationService, IOptions<SiteSettings> siteSettings)
|
||||
{
|
||||
_context = context;
|
||||
_site = siteSettings.Value;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
// GET: Estimate
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
return View(_context.Estimates.Include(e=>e.Query)
|
||||
.Include(e=>e.Query.PerformerProfile)
|
||||
.Include(e=>e.Query.PerformerProfile.Performer)
|
||||
.Where(
|
||||
e=>e.OwnerId == uid || e.ClientId == uid
|
||||
).OrderByDescending(e=>e.ProviderValidationDate)
|
||||
.ToList());
|
||||
}
|
||||
|
||||
// GET: Estimate/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
.Include(e => e.Query)
|
||||
.Include(e => e.Query.PerformerProfile)
|
||||
.Include(e => e.Query.PerformerProfile.Performer)
|
||||
.Include(e=> e.Bill)
|
||||
.Where(
|
||||
e=>e.OwnerId == uid || e.ClientId == uid
|
||||
)
|
||||
.Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
|
||||
// GET: Estimate/Create
|
||||
[Authorize]
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
IQueryable<RdvQuery> queries = _context.RdvQueries.Include(q=>q.Location).Where(bq=>bq.PerformerId == uid);
|
||||
//.Select(bq=>new SelectListItem{ Text = bq.Client.UserName, Value = bq.Client.Id });
|
||||
ViewBag.Clients = queries.Select(q=>q.Client).Distinct();
|
||||
ViewBag.Queries = queries;
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Estimate/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Estimate estimate,
|
||||
ICollection<IFormFile> newGraphics,
|
||||
ICollection<IFormFile> newFiles
|
||||
)
|
||||
{
|
||||
estimate.OwnerId = User.GetUserId();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Estimates
|
||||
.Add(estimate);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
var query = _context.RdvQueries.FirstOrDefault(
|
||||
q=>q.Id == estimate.CommandId
|
||||
);
|
||||
var perfomerProfile = _context.Performers
|
||||
.Include(
|
||||
perpr => perpr.Performer).FirstOrDefault(
|
||||
x=>x.PerformerId == query.PerformerId
|
||||
);
|
||||
var command = _context.RdvQueries.FirstOrDefault(
|
||||
cmd => cmd.Id == estimate.CommandId
|
||||
);
|
||||
|
||||
var billsdir = Path.Combine(
|
||||
_site.UserFiles.Bills,
|
||||
perfomerProfile.Performer.UserName
|
||||
);
|
||||
|
||||
foreach (var gr in newGraphics)
|
||||
{
|
||||
ContentDisposition contentDisposition = new ContentDisposition(gr.ContentDisposition);
|
||||
gr.SaveAs(
|
||||
Path.Combine(
|
||||
Path.Combine(billsdir, estimate.Id.ToString()),
|
||||
contentDisposition.FileName));
|
||||
}
|
||||
foreach (var formFile in newFiles)
|
||||
{
|
||||
ContentDisposition contentDisposition = new ContentDisposition(formFile.ContentDisposition);
|
||||
formFile.SaveAs(
|
||||
Path.Combine(
|
||||
Path.Combine(billsdir, estimate.Id.ToString()),
|
||||
contentDisposition.FileName));
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
|
||||
private void Save(ICollection<IFormFile> newGraphics,
|
||||
ICollection<IFormFile> newFiles) {
|
||||
|
||||
}
|
||||
// GET: Estimate/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
.Where(e=>e.OwnerId==uid||e.ClientId==uid).Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
ViewBag.Files = User.GetUserFiles(null);
|
||||
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
// POST: Estimate/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Estimate estimate)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (estimate.OwnerId!=uid&&estimate.ClientId!=uid
|
||||
) return new HttpNotFoundResult();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(estimate);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
// GET: Estimate/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
.Where(e=>e.OwnerId==uid||e.ClientId==uid) .Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
// POST: Estimate/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
Estimate estimate = _context.Estimates.Single(m => m.Id == id);
|
||||
_context.Estimates.Remove(estimate);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using Helpers;
|
||||
using Models;
|
||||
using Models.Billing;
|
||||
using Models.Workflow;
|
||||
using ViewModels.Auth;
|
||||
using Yavsc.Abstract.FileSystem;
|
||||
|
||||
[Authorize]
|
||||
public class EstimateController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
private SiteSettings _site;
|
||||
|
||||
IAuthorizationService authorizationService;
|
||||
|
||||
public EstimateController(ApplicationDbContext context, IAuthorizationService authorizationService, IOptions<SiteSettings> siteSettings)
|
||||
{
|
||||
_context = context;
|
||||
_site = siteSettings.Value;
|
||||
this.authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
// GET: Estimate
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
return View(_context.Estimates.Include(e=>e.Query)
|
||||
.Include(e=>e.Query.PerformerProfile)
|
||||
.Include(e=>e.Query.PerformerProfile.Performer)
|
||||
.Where(
|
||||
e=>e.OwnerId == uid || e.ClientId == uid
|
||||
).OrderByDescending(e=>e.ProviderValidationDate)
|
||||
.ToList());
|
||||
}
|
||||
|
||||
// GET: Estimate/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
.Include(e => e.Query)
|
||||
.Include(e => e.Query.PerformerProfile)
|
||||
.Include(e => e.Query.PerformerProfile.Performer)
|
||||
.Include(e=> e.Bill)
|
||||
.Where(
|
||||
e=>e.OwnerId == uid || e.ClientId == uid
|
||||
)
|
||||
.Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (!await authorizationService.AuthorizeAsync(User, estimate, new ViewRequirement()))
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
|
||||
// GET: Estimate/Create
|
||||
[Authorize]
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
IQueryable<RdvQuery> queries = _context.RdvQueries.Include(q=>q.Location).Where(bq=>bq.PerformerId == uid);
|
||||
//.Select(bq=>new SelectListItem{ Text = bq.Client.UserName, Value = bq.Client.Id });
|
||||
ViewBag.Clients = queries.Select(q=>q.Client).Distinct();
|
||||
ViewBag.Queries = queries;
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Estimate/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Estimate estimate,
|
||||
ICollection<IFormFile> newGraphics,
|
||||
ICollection<IFormFile> newFiles
|
||||
)
|
||||
{
|
||||
estimate.OwnerId = User.GetUserId();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Estimates
|
||||
.Add(estimate);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
var query = _context.RdvQueries.FirstOrDefault(
|
||||
q=>q.Id == estimate.CommandId
|
||||
);
|
||||
var perfomerProfile = _context.Performers
|
||||
.Include(
|
||||
perpr => perpr.Performer).FirstOrDefault(
|
||||
x=>x.PerformerId == query.PerformerId
|
||||
);
|
||||
var command = _context.RdvQueries.FirstOrDefault(
|
||||
cmd => cmd.Id == estimate.CommandId
|
||||
);
|
||||
|
||||
var billsdir = Path.Combine(
|
||||
_site.UserFiles.Bills,
|
||||
perfomerProfile.Performer.UserName
|
||||
);
|
||||
|
||||
foreach (var gr in newGraphics)
|
||||
{
|
||||
ContentDisposition contentDisposition = new ContentDisposition(gr.ContentDisposition);
|
||||
gr.SaveAs(
|
||||
Path.Combine(
|
||||
Path.Combine(billsdir, estimate.Id.ToString()),
|
||||
contentDisposition.FileName));
|
||||
}
|
||||
foreach (var formFile in newFiles)
|
||||
{
|
||||
ContentDisposition contentDisposition = new ContentDisposition(formFile.ContentDisposition);
|
||||
formFile.SaveAs(
|
||||
Path.Combine(
|
||||
Path.Combine(billsdir, estimate.Id.ToString()),
|
||||
contentDisposition.FileName));
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
|
||||
private void Save(ICollection<IFormFile> newGraphics,
|
||||
ICollection<IFormFile> newFiles) {
|
||||
|
||||
}
|
||||
// GET: Estimate/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
.Where(e=>e.OwnerId==uid||e.ClientId==uid).Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
ViewBag.Files = User.GetUserFiles(null);
|
||||
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
// POST: Estimate/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Estimate estimate)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (estimate.OwnerId!=uid&&estimate.ClientId!=uid
|
||||
) return new HttpNotFoundResult();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(estimate);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
// GET: Estimate/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
|
||||
Estimate estimate = _context.Estimates
|
||||
.Where(e=>e.OwnerId==uid||e.ClientId==uid) .Single(m => m.Id == id);
|
||||
if (estimate == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(estimate);
|
||||
}
|
||||
|
||||
// POST: Estimate/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
Estimate estimate = _context.Estimates.Single(m => m.Id == id);
|
||||
_context.Estimates.Remove(estimate);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
using Yavsc.Controllers.Generic;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow.Profiles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class FormationSettingsController : SettingsController<FormationSettings>
|
||||
{
|
||||
|
||||
public FormationSettingsController(ApplicationDbContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using Yavsc.Controllers.Generic;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Workflow.Profiles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class FormationSettingsController : SettingsController<FormationSettings>
|
||||
{
|
||||
|
||||
public FormationSettingsController(ApplicationDbContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,121 +1,121 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Forms;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class FormsController : Controller
|
||||
{
|
||||
private 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 HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
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 HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
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 HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Forms;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class FormsController : Controller
|
||||
{
|
||||
private 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 HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
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 HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
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 HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +1,120 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class GeneralSettingsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public GeneralSettingsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: GeneralSettings
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.GeneralSettings.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: GeneralSettings/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// GET: GeneralSettings/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: GeneralSettings/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(GeneralSettings generalSettings)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.GeneralSettings.Add(generalSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// GET: GeneralSettings/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// POST: GeneralSettings/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(GeneralSettings generalSettings)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(generalSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// GET: GeneralSettings/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// POST: GeneralSettings/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
_context.GeneralSettings.Remove(generalSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class GeneralSettingsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public GeneralSettingsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: GeneralSettings
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.GeneralSettings.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: GeneralSettings/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// GET: GeneralSettings/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: GeneralSettings/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(GeneralSettings generalSettings)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.GeneralSettings.Add(generalSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// GET: GeneralSettings/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// POST: GeneralSettings/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(GeneralSettings generalSettings)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(generalSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// GET: GeneralSettings/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(generalSettings);
|
||||
}
|
||||
|
||||
// POST: GeneralSettings/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
GeneralSettings generalSettings = await _context.GeneralSettings.SingleAsync(m => m.UserId == id);
|
||||
_context.GeneralSettings.Remove(generalSettings);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Controllers.Generic;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize(Roles="Performer")]
|
||||
public class BrusherProfileController : SettingsController<BrusherProfile>
|
||||
{
|
||||
public BrusherProfileController(ApplicationDbContext context) : base(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Yavsc.Controllers.Generic;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize(Roles="Performer")]
|
||||
public class BrusherProfileController : SettingsController<BrusherProfile>
|
||||
{
|
||||
public BrusherProfileController(ApplicationDbContext context) : base(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,121 +1,121 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Drawing;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class ColorsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public ColorsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Colors
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Color.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Colors/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// GET: Colors/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View(new Color());
|
||||
}
|
||||
|
||||
// POST: Colors/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Color color)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Color.Add(color);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// GET: Colors/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// POST: Colors/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Color color)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(color);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// GET: Colors/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// POST: Colors/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
_context.Color.Remove(color);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Drawing;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class ColorsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public ColorsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Colors
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Color.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Colors/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// GET: Colors/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View(new Color());
|
||||
}
|
||||
|
||||
// POST: Colors/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Color color)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Color.Add(color);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// GET: Colors/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// POST: Colors/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Color color)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(color);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// GET: Colors/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
if (color == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(color);
|
||||
}
|
||||
|
||||
// POST: Colors/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Color color = await _context.Color.SingleAsync(m => m.Id == id);
|
||||
_context.Color.Remove(color);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +1,120 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class HairPrestationsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public HairPrestationsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: HairPrestations
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.HairPrestation.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: HairPrestations/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// GET: HairPrestations/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HairPrestations/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(HairPrestation hairPrestation)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.HairPrestation.Add(hairPrestation);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// GET: HairPrestations/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// POST: HairPrestations/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(HairPrestation hairPrestation)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(hairPrestation);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// GET: HairPrestations/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// POST: HairPrestations/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
_context.HairPrestation.Remove(hairPrestation);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class HairPrestationsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public HairPrestationsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: HairPrestations
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.HairPrestation.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: HairPrestations/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// GET: HairPrestations/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HairPrestations/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(HairPrestation hairPrestation)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.HairPrestation.Add(hairPrestation);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// GET: HairPrestations/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// POST: HairPrestations/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(HairPrestation hairPrestation)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(hairPrestation);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// GET: HairPrestations/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
if (hairPrestation == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hairPrestation);
|
||||
}
|
||||
|
||||
// POST: HairPrestations/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
HairPrestation hairPrestation = await _context.HairPrestation.SingleAsync(m => m.Id == id);
|
||||
_context.HairPrestation.Remove(hairPrestation);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,129 +1,129 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class HairTaintsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public HairTaintsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: HairTaints
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var applicationDbContext = _context.HairTaint.Include(h => h.Color);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: HairTaints/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// GET: HairTaints/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HairTaints/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(HairTaint hairTaint)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.HairTaint.Add(hairTaint);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// GET: HairTaints/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name",hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// POST: HairTaints/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(HairTaint hairTaint)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(hairTaint);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// GET: HairTaints/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// POST: HairTaints/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
_context.HairTaint.Remove(hairTaint);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Haircut;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class HairTaintsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public HairTaintsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: HairTaints
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var applicationDbContext = _context.HairTaint.Include(h => h.Color);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: HairTaints/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// GET: HairTaints/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HairTaints/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(HairTaint hairTaint)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.HairTaint.Add(hairTaint);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// GET: HairTaints/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name",hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// POST: HairTaints/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(HairTaint hairTaint)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(hairTaint);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewBag.ColorId = new SelectList(_context.Color, "Id", "Name", hairTaint.ColorId);
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// GET: HairTaints/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
if (hairTaint == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hairTaint);
|
||||
}
|
||||
|
||||
// POST: HairTaints/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
HairTaint hairTaint = await _context.HairTaint.SingleAsync(m => m.Id == id);
|
||||
_context.HairTaint.Remove(hairTaint);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,149 +1,149 @@
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
public class InstrumentationController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public InstrumentationController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Instrumentation
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Instrumentation.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Instrumentation/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
||||
// GET: Instrumentation/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var owned = _context.Instrumentation.Include(i=>i.Tool).Where(i=>i.UserId==uid).Select(i=>i.InstrumentId);
|
||||
var ownedArray = owned.ToArray();
|
||||
|
||||
ViewBag.YetAvailableInstruments = _context.Instrument.Select(k=>new SelectListItem
|
||||
{ Text = k.Name, Value = k.Id.ToString(), Disabled = ownedArray.Contains(k.Id) });
|
||||
|
||||
return View(new Instrumentation { UserId = uid });
|
||||
}
|
||||
|
||||
// POST: Instrumentation/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Instrumentation model)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (model.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
_context.Instrumentation.Add(model);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// GET: Instrumentation/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (id != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
||||
// POST: Instrumentation/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Instrumentation musicianSettings)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(musicianSettings);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
||||
// GET: Instrumentation/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
||||
// POST: Instrumentation/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
|
||||
var uid = User.GetUserId();
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
|
||||
_context.Instrumentation.Remove(musicianSettings);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Musical.Profiles;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
public class InstrumentationController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public InstrumentationController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Instrumentation
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Instrumentation.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Instrumentation/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
||||
// GET: Instrumentation/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var owned = _context.Instrumentation.Include(i=>i.Tool).Where(i=>i.UserId==uid).Select(i=>i.InstrumentId);
|
||||
var ownedArray = owned.ToArray();
|
||||
|
||||
ViewBag.YetAvailableInstruments = _context.Instrument.Select(k=>new SelectListItem
|
||||
{ Text = k.Name, Value = k.Id.ToString(), Disabled = ownedArray.Contains(k.Id) });
|
||||
|
||||
return View(new Instrumentation { UserId = uid });
|
||||
}
|
||||
|
||||
// POST: Instrumentation/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Instrumentation model)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (model.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
_context.Instrumentation.Add(model);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// GET: Instrumentation/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (id != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
||||
// POST: Instrumentation/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Instrumentation musicianSettings)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(musicianSettings);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
||||
// GET: Instrumentation/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
var uid = User.GetUserId();
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
||||
// POST: Instrumentation/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
|
||||
var uid = User.GetUserId();
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
|
||||
_context.Instrumentation.Remove(musicianSettings);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +1,120 @@
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
using Models.Musical;
|
||||
public class InstrumentsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public InstrumentsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Instruments
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View(_context.Instrument.ToList());
|
||||
}
|
||||
|
||||
// GET: Instruments/Details/5
|
||||
public IActionResult Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// GET: Instruments/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Instruments/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Instrument instrument)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Instrument.Add(instrument);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// GET: Instruments/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// POST: Instruments/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Instrument instrument)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(instrument);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// GET: Instruments/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// POST: Instruments/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
_context.Instrument.Remove(instrument);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
using Models.Musical;
|
||||
public class InstrumentsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public InstrumentsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Instruments
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View(_context.Instrument.ToList());
|
||||
}
|
||||
|
||||
// GET: Instruments/Details/5
|
||||
public IActionResult Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// GET: Instruments/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Instruments/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Instrument instrument)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Instrument.Add(instrument);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// GET: Instruments/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// POST: Instruments/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Instrument instrument)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(instrument);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// GET: Instruments/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
if (instrument == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(instrument);
|
||||
}
|
||||
|
||||
// POST: Instruments/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
Instrument instrument = _context.Instrument.Single(m => m.Id == id);
|
||||
_context.Instrument.Remove(instrument);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +1,120 @@
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
using Models.Musical;
|
||||
public class MusicalTendenciesController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public MusicalTendenciesController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View(_context.MusicalTendency.ToList());
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies/Details/5
|
||||
public IActionResult Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: MusicalTendencies/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(MusicalTendency musicalTendency)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.MusicalTendency.Add(musicalTendency);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// POST: MusicalTendencies/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(MusicalTendency musicalTendency)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(musicalTendency);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// POST: MusicalTendencies/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
_context.MusicalTendency.Remove(musicalTendency);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
using System.Security.Claims;
|
||||
using Models;
|
||||
using Models.Musical;
|
||||
public class MusicalTendenciesController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public MusicalTendenciesController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View(_context.MusicalTendency.ToList());
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies/Details/5
|
||||
public IActionResult Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: MusicalTendencies/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(MusicalTendency musicalTendency)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.MusicalTendency.Add(musicalTendency);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies/Edit/5
|
||||
public IActionResult Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// POST: MusicalTendencies/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(MusicalTendency musicalTendency)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(musicalTendency);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// GET: MusicalTendencies/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
if (musicalTendency == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(musicalTendency);
|
||||
}
|
||||
|
||||
// POST: MusicalTendencies/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
MusicalTendency musicalTendency = _context.MusicalTendency.Single(m => m.Id == id);
|
||||
_context.MusicalTendency.Remove(musicalTendency);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,259 +1,259 @@
|
||||
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Yavsc.ViewModels.Blogspot;
|
||||
using Yavsc.Models.Blog;
|
||||
// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class BlogspotController : Controller
|
||||
{
|
||||
ILogger _logger;
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
private SiteSettings _siteSettings;
|
||||
private IAuthorizationService _authorizationService;
|
||||
public BlogspotController(
|
||||
ApplicationDbContext context,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ILoggerFactory loggerFactory,
|
||||
IAuthorizationService authorizationService,
|
||||
IOptions<SiteSettings> siteSettings)
|
||||
{
|
||||
_context = context;
|
||||
_logger = loggerFactory.CreateLogger<AccountController>();
|
||||
_authorizationService = authorizationService;
|
||||
_siteSettings = siteSettings.Value;
|
||||
}
|
||||
|
||||
// GET: Blog
|
||||
[AllowAnonymous]
|
||||
public IActionResult Index(string id, int skip=0, int maxLen=25)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
return UserPosts(id);
|
||||
string uid = User.GetUserId();
|
||||
long[] usercircles = _context.Circle.Include(c=>c.Members).Where(c=>c.Members.Any(m=>m.MemberId == uid))
|
||||
.Select(c=>c.Id).ToArray();
|
||||
IQueryable<BlogPost> posts ;
|
||||
var allposts = _context.Blogspot
|
||||
.Include(b => b.Author)
|
||||
.Include(p=>p.ACL)
|
||||
.Include(p=>p.Tags)
|
||||
.Include(p=>p.Comments)
|
||||
.Where(p=>p.AuthorId == uid || p.Visible);
|
||||
|
||||
if (usercircles != null) {
|
||||
posts = allposts.Where(p=> p.ACL.Count==0 || p.ACL.Any(a=> usercircles.Contains(a.CircleId)))
|
||||
;
|
||||
}
|
||||
else {
|
||||
posts = allposts.Where(p => p.ACL.Count == 0);
|
||||
}
|
||||
|
||||
var data = posts.OrderByDescending( p=> p.DateCreated).ToArray();
|
||||
var grouped = data.GroupBy(p=> p.Title).Skip(skip).Take(maxLen);
|
||||
|
||||
return View(grouped);
|
||||
}
|
||||
|
||||
[Route("/Title/{id?}")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult Title(string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
ViewData["Title"] = id;
|
||||
return View("Title", _context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Where(x => x.Title == id && (x.Visible || x.AuthorId == uid )).OrderByDescending(
|
||||
x => x.DateCreated
|
||||
).ToList());
|
||||
}
|
||||
|
||||
[Route("/Blog/{id?}")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult UserPosts(string id)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(id)) return Index(null);
|
||||
var uid = User.GetUserId();
|
||||
long[] usercircles = _context.Circle.Include(c=>c.Members).Where(c=>c.Members.Any(m=>m.MemberId == uid))
|
||||
.Select(c=>c.Id).ToArray();
|
||||
var result = (User.IsSignedIn())?
|
||||
_context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Include(p=>p.ACL).Where(x => x.Author.UserName == id && (x.Visible && (x.ACL.Count==0 || x.ACL.Any(a=> usercircles.Contains(a.CircleId))))):
|
||||
_context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Where(x => x.Author.UserName == id && x.Visible);
|
||||
// BlogIndexKey
|
||||
return View("Index", result.OrderByDescending(p => p.DateCreated).ToList().GroupBy(p=> p.Title ));
|
||||
}
|
||||
// GET: Blog/Details/5
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
BlogPost blog = _context.Blogspot
|
||||
.Include(p => p.Author)
|
||||
.Include(p => p.Tags)
|
||||
.Include(p => p.Comments)
|
||||
.Include(p => p.ACL)
|
||||
.Single(m => m.Id == id);
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (!await _authorizationService.AuthorizeAsync(User, blog, new ViewRequirement()))
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
foreach (var c in blog.Comments) {
|
||||
c.Author = _context.Users.First(u=>u.Id==c.AuthorId);
|
||||
}
|
||||
ViewData["apicmtctlr"] = "/api/blogcomments";
|
||||
ViewData["moderatoFlag"] = User.IsInRole(Constants.BlogModeratorGroupName);
|
||||
return View(blog);
|
||||
}
|
||||
|
||||
// GET: Blog/Create
|
||||
[Authorize()]
|
||||
public IActionResult Create(string title)
|
||||
{
|
||||
var result = new BlogPost{Title=title};
|
||||
ViewData["PostTarget"]="Create";
|
||||
return View("Edit",result);
|
||||
}
|
||||
|
||||
// POST: Blog/Create
|
||||
[HttpPost, Authorize, ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Models.Blog.BlogPost blog)
|
||||
{
|
||||
blog.Rate = 0;
|
||||
blog.AuthorId = User.GetUserId();
|
||||
blog.Id=0;
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
||||
_context.Blogspot.Add(blog);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ModelState.AddModelError("Unknown","Invalid Blog posted ...");
|
||||
ViewData["PostTarget"]="Create";
|
||||
return View("Edit",blog);
|
||||
}
|
||||
[Authorize()]
|
||||
// GET: Blog/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
ViewData["PostTarget"]="Edit";
|
||||
BlogPost blog = _context.Blogspot.Include(x => x.Author).Include(x => x.ACL).Single(m => m.Id == id);
|
||||
|
||||
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (await _authorizationService.AuthorizeAsync(User, blog, new EditRequirement()))
|
||||
{
|
||||
ViewBag.ACL = _context.Circle.Where(
|
||||
c=>c.OwnerId == blog.AuthorId)
|
||||
.Select(
|
||||
c => new SelectListItem
|
||||
{
|
||||
Text = c.Name,
|
||||
Value = c.Id.ToString(),
|
||||
Selected = blog.AuthorizeCircle(c.Id)
|
||||
}
|
||||
);
|
||||
return View(blog);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
}
|
||||
|
||||
// POST: Blog/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken,Authorize()]
|
||||
public IActionResult Edit(BlogPost blog)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var auth = _authorizationService.AuthorizeAsync(User, blog, new EditRequirement());
|
||||
if (auth.Result)
|
||||
{
|
||||
// saves the change
|
||||
_context.Update(blog);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
ViewData["StatusMessage"] = "Post modified";
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewData["StatusMessage"] = "Accès restreint";
|
||||
return new ChallengeResult();
|
||||
}
|
||||
}
|
||||
ViewData["PostTarget"]="Edit";
|
||||
return View(blog);
|
||||
}
|
||||
|
||||
// GET: Blog/Delete/5
|
||||
[ActionName("Delete"),Authorize()]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
BlogPost blog = _context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Single(m => m.Id == id);
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(blog);
|
||||
}
|
||||
|
||||
// POST: Blog/Delete/5
|
||||
[HttpPost, ActionName("Delete"), Authorize()]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
BlogPost blog = _context.Blogspot.Single(m => m.Id == id);
|
||||
var auth = _authorizationService.AuthorizeAsync(User, blog, new EditRequirement());
|
||||
if (auth.Result)
|
||||
{
|
||||
_context.Blogspot.Remove(blog);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.Data.Entity;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Yavsc.ViewModels.Blogspot;
|
||||
using Yavsc.Models.Blog;
|
||||
// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class BlogspotController : Controller
|
||||
{
|
||||
ILogger _logger;
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
private SiteSettings _siteSettings;
|
||||
private IAuthorizationService _authorizationService;
|
||||
public BlogspotController(
|
||||
ApplicationDbContext context,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ILoggerFactory loggerFactory,
|
||||
IAuthorizationService authorizationService,
|
||||
IOptions<SiteSettings> siteSettings)
|
||||
{
|
||||
_context = context;
|
||||
_logger = loggerFactory.CreateLogger<AccountController>();
|
||||
_authorizationService = authorizationService;
|
||||
_siteSettings = siteSettings.Value;
|
||||
}
|
||||
|
||||
// GET: Blog
|
||||
[AllowAnonymous]
|
||||
public IActionResult Index(string id, int skip=0, int maxLen=25)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
return UserPosts(id);
|
||||
string uid = User.GetUserId();
|
||||
long[] usercircles = _context.Circle.Include(c=>c.Members).Where(c=>c.Members.Any(m=>m.MemberId == uid))
|
||||
.Select(c=>c.Id).ToArray();
|
||||
IQueryable<BlogPost> posts ;
|
||||
var allposts = _context.Blogspot
|
||||
.Include(b => b.Author)
|
||||
.Include(p=>p.ACL)
|
||||
.Include(p=>p.Tags)
|
||||
.Include(p=>p.Comments)
|
||||
.Where(p=>p.AuthorId == uid || p.Visible);
|
||||
|
||||
if (usercircles != null) {
|
||||
posts = allposts.Where(p=> p.ACL.Count==0 || p.ACL.Any(a=> usercircles.Contains(a.CircleId)))
|
||||
;
|
||||
}
|
||||
else {
|
||||
posts = allposts.Where(p => p.ACL.Count == 0);
|
||||
}
|
||||
|
||||
var data = posts.OrderByDescending( p=> p.DateCreated).ToArray();
|
||||
var grouped = data.GroupBy(p=> p.Title).Skip(skip).Take(maxLen);
|
||||
|
||||
return View(grouped);
|
||||
}
|
||||
|
||||
[Route("/Title/{id?}")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult Title(string id)
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
ViewData["Title"] = id;
|
||||
return View("Title", _context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Where(x => x.Title == id && (x.Visible || x.AuthorId == uid )).OrderByDescending(
|
||||
x => x.DateCreated
|
||||
).ToList());
|
||||
}
|
||||
|
||||
[Route("/Blog/{id?}")]
|
||||
[AllowAnonymous]
|
||||
public IActionResult UserPosts(string id)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(id)) return Index(null);
|
||||
var uid = User.GetUserId();
|
||||
long[] usercircles = _context.Circle.Include(c=>c.Members).Where(c=>c.Members.Any(m=>m.MemberId == uid))
|
||||
.Select(c=>c.Id).ToArray();
|
||||
var result = (User.IsSignedIn())?
|
||||
_context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Include(p=>p.ACL).Where(x => x.Author.UserName == id && (x.Visible && (x.ACL.Count==0 || x.ACL.Any(a=> usercircles.Contains(a.CircleId))))):
|
||||
_context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Where(x => x.Author.UserName == id && x.Visible);
|
||||
// BlogIndexKey
|
||||
return View("Index", result.OrderByDescending(p => p.DateCreated).ToList().GroupBy(p=> p.Title ));
|
||||
}
|
||||
// GET: Blog/Details/5
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
BlogPost blog = _context.Blogspot
|
||||
.Include(p => p.Author)
|
||||
.Include(p => p.Tags)
|
||||
.Include(p => p.Comments)
|
||||
.Include(p => p.ACL)
|
||||
.Single(m => m.Id == id);
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (!await _authorizationService.AuthorizeAsync(User, blog, new ViewRequirement()))
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
foreach (var c in blog.Comments) {
|
||||
c.Author = _context.Users.First(u=>u.Id==c.AuthorId);
|
||||
}
|
||||
ViewData["apicmtctlr"] = "/api/blogcomments";
|
||||
ViewData["moderatoFlag"] = User.IsInRole(Constants.BlogModeratorGroupName);
|
||||
return View(blog);
|
||||
}
|
||||
|
||||
// GET: Blog/Create
|
||||
[Authorize()]
|
||||
public IActionResult Create(string title)
|
||||
{
|
||||
var result = new BlogPost{Title=title};
|
||||
ViewData["PostTarget"]="Create";
|
||||
return View("Edit",result);
|
||||
}
|
||||
|
||||
// POST: Blog/Create
|
||||
[HttpPost, Authorize, ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Models.Blog.BlogPost blog)
|
||||
{
|
||||
blog.Rate = 0;
|
||||
blog.AuthorId = User.GetUserId();
|
||||
blog.Id=0;
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
||||
_context.Blogspot.Add(blog);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ModelState.AddModelError("Unknown","Invalid Blog posted ...");
|
||||
ViewData["PostTarget"]="Create";
|
||||
return View("Edit",blog);
|
||||
}
|
||||
[Authorize()]
|
||||
// GET: Blog/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
ViewData["PostTarget"]="Edit";
|
||||
BlogPost blog = _context.Blogspot.Include(x => x.Author).Include(x => x.ACL).Single(m => m.Id == id);
|
||||
|
||||
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
if (await _authorizationService.AuthorizeAsync(User, blog, new EditRequirement()))
|
||||
{
|
||||
ViewBag.ACL = _context.Circle.Where(
|
||||
c=>c.OwnerId == blog.AuthorId)
|
||||
.Select(
|
||||
c => new SelectListItem
|
||||
{
|
||||
Text = c.Name,
|
||||
Value = c.Id.ToString(),
|
||||
Selected = blog.AuthorizeCircle(c.Id)
|
||||
}
|
||||
);
|
||||
return View(blog);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
}
|
||||
|
||||
// POST: Blog/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken,Authorize()]
|
||||
public IActionResult Edit(BlogPost blog)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
var auth = _authorizationService.AuthorizeAsync(User, blog, new EditRequirement());
|
||||
if (auth.Result)
|
||||
{
|
||||
// saves the change
|
||||
_context.Update(blog);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
ViewData["StatusMessage"] = "Post modified";
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewData["StatusMessage"] = "Accès restreint";
|
||||
return new ChallengeResult();
|
||||
}
|
||||
}
|
||||
ViewData["PostTarget"]="Edit";
|
||||
return View(blog);
|
||||
}
|
||||
|
||||
// GET: Blog/Delete/5
|
||||
[ActionName("Delete"),Authorize()]
|
||||
public IActionResult Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
BlogPost blog = _context.Blogspot.Include(
|
||||
b => b.Author
|
||||
).Single(m => m.Id == id);
|
||||
if (blog == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(blog);
|
||||
}
|
||||
|
||||
// POST: Blog/Delete/5
|
||||
[HttpPost, ActionName("Delete"), Authorize()]
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult DeleteConfirmed(long id)
|
||||
{
|
||||
BlogPost blog = _context.Blogspot.Single(m => m.Id == id);
|
||||
var auth = _authorizationService.AuthorizeAsync(User, blog, new EditRequirement());
|
||||
if (auth.Result)
|
||||
{
|
||||
_context.Blogspot.Remove(blog);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,121 +1,121 @@
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Messaging;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class NotificationsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public NotificationsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Notifications
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Notification.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Notifications/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// GET: Notifications/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Notifications/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Notification notification)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Notification.Add(notification);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// GET: Notifications/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// POST: Notifications/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Notification notification)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(notification);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// GET: Notifications/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// POST: Notifications/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
_context.Notification.Remove(notification);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Messaging;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class NotificationsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public NotificationsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Notifications
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Notification.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Notifications/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// GET: Notifications/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Notifications/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Notification notification)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Notification.Add(notification);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// GET: Notifications/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// POST: Notifications/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Notification notification)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(notification);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// GET: Notifications/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
if (notification == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(notification);
|
||||
}
|
||||
|
||||
// POST: Notifications/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
Notification notification = await _context.Notification.SingleAsync(m => m.Id == id);
|
||||
_context.Notification.Remove(notification);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user