enrolment
This commit is contained in:
parent
4c496e08d1
commit
152276f9ed
17 changed files with 174 additions and 64 deletions
129
src/Yavsc/Controllers/Communicating/HyperLinkController.cs
Normal file
129
src/Yavsc/Controllers/Communicating/HyperLinkController.cs
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class HyperLinkController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public HyperLinkController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: HyperLink
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.HyperLink.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: HyperLink/Details/5
|
||||
public async Task<IActionResult> Details(string href, string method)
|
||||
{
|
||||
if (href == null || method ==null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == href && m.Method == method);
|
||||
if (hyperLink == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hyperLink);
|
||||
}
|
||||
|
||||
// GET: HyperLink/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: HyperLink/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(HyperLink hyperLink)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.HyperLink.Add(hyperLink);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(hyperLink);
|
||||
}
|
||||
|
||||
// GET: HyperLink/Edit/5
|
||||
public async Task<IActionResult> Edit(string href, string method)
|
||||
{
|
||||
if (href == null || method ==null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == href && m.Method == method);
|
||||
if (hyperLink == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(hyperLink);
|
||||
}
|
||||
|
||||
// POST: HyperLink/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(HyperLink hyperLink)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(hyperLink);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(hyperLink);
|
||||
}
|
||||
|
||||
// GET: HyperLink/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string href, string method)
|
||||
{
|
||||
if (href == null || method ==null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == href && m.Method == method);
|
||||
|
||||
if (hyperLink == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(hyperLink);
|
||||
}
|
||||
|
||||
// POST: HyperLink/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string HRef, string Method)
|
||||
{
|
||||
if (HRef == null || Method ==null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
HyperLink hyperLink = await _context.HyperLink.SingleAsync(m => m.HRef == HRef && m.Method == Method);
|
||||
|
||||
_context.HyperLink.Remove(hyperLink);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
183
src/Yavsc/Controllers/Communicating/LiveFlowController.cs
Normal file
183
src/Yavsc/Controllers/Communicating/LiveFlowController.cs
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Streaming;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class LiveFlowController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public LiveFlowController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: LiveFlow
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var uid = User.GetUserId();
|
||||
var applicationDbContext = _context.LiveFlow.Where(f=>f.OwnerId == uid);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> AdminIndex()
|
||||
{
|
||||
var applicationDbContext = _context.LiveFlow.Include(l => l.Owner);
|
||||
return View(await applicationDbContext.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: LiveFlow/Details/5
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
if (liveFlow == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
// GET: LiveFlow/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["OwnerId"] = new SelectList(_context.ApplicationUser, "Id", "Owner");
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: LiveFlow/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(LiveFlow liveFlow)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.LiveFlow.Add(liveFlow);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["OwnerId"] = new SelectList(_context.ApplicationUser, "Id", "Owner", liveFlow.OwnerId);
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
// GET: LiveFlow/Edit/5
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
if (liveFlow == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> AdminEdit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
if (liveFlow == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
ViewBag.OwnerId = _context.ApplicationUser.Select
|
||||
(u=> new SelectListItem(){Text=u.UserName,Value=u.Id,Selected=liveFlow.OwnerId==u.Id});
|
||||
return View("AdminEdit", liveFlow);
|
||||
}
|
||||
// POST: LiveFlow/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(LiveFlow liveFlow)
|
||||
{
|
||||
if (User.GetUserId()!=liveFlow.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId","denied");
|
||||
}
|
||||
else if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(liveFlow);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
|
||||
// POST: LiveFlow/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public async Task<IActionResult> AdminEdit(LiveFlow liveFlow)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(liveFlow);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["OwnerId"] = new SelectList(_context.ApplicationUser, "Id", "Owner", liveFlow.OwnerId);
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
// GET: LiveFlow/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
|
||||
if (liveFlow == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
else if (User.GetUserId()!=liveFlow.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId","denied");
|
||||
}
|
||||
|
||||
return View(liveFlow);
|
||||
}
|
||||
|
||||
// POST: LiveFlow/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
LiveFlow liveFlow = await _context.LiveFlow.SingleAsync(m => m.Id == id);
|
||||
if (User.GetUserId()!=liveFlow.OwnerId)
|
||||
{
|
||||
ModelState.AddModelError("OwnerId","denied");
|
||||
} else
|
||||
{
|
||||
_context.LiveFlow.Remove(liveFlow);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue