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