command forms :-)
This commit is contained in:
@ -4,6 +4,7 @@ using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Forms;
|
||||
using Yavsc.Models.Workflow;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
@ -25,7 +26,7 @@ namespace Yavsc.Controllers
|
||||
}
|
||||
|
||||
// GET: CommandForms/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
public async Task<IActionResult> Details(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
@ -44,7 +45,8 @@ namespace Yavsc.Controllers
|
||||
// GET: CommandForms/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context");
|
||||
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Name");
|
||||
ViewBag.ViewName = YavscLib.YavscConstants.Forms.Select( c => new SelectListItem { Text = c } );
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -60,11 +62,12 @@ namespace Yavsc.Controllers
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", commandForm.ActivityCode);
|
||||
ViewData["FormId"] = new SelectList(_context.Set<Form>(), "Id", "Form", commandForm.ViewName);
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// GET: CommandForms/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
public async Task<IActionResult> Edit(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
@ -77,6 +80,7 @@ namespace Yavsc.Controllers
|
||||
return HttpNotFound();
|
||||
}
|
||||
ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", commandForm.ActivityCode);
|
||||
ViewData["FormId"] = new SelectList(_context.Set<Form>(), "Id", "Form", commandForm.ViewName);
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
@ -91,13 +95,14 @@ namespace Yavsc.Controllers
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
ViewData["ActivityCode"] = new SelectList(_context.Activities, "Code", "Context", commandForm.ActivityCode);
|
||||
ViewBag.ActivityCode = new SelectList(_context.Activities, "Code", "Context", commandForm.ActivityCode);
|
||||
ViewBag.ViewName = YavscLib.YavscConstants.Forms.Select( c => new SelectListItem { Text = c } );
|
||||
return View(commandForm);
|
||||
}
|
||||
|
||||
// GET: CommandForms/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
public async Task<IActionResult> Delete(long? id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
@ -116,7 +121,7 @@ namespace Yavsc.Controllers
|
||||
// POST: CommandForms/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||
{
|
||||
CommandForm commandForm = await _context.CommandForm.SingleAsync(m => m.Id == id);
|
||||
_context.CommandForm.Remove(commandForm);
|
||||
|
122
Yavsc/Controllers/FormsController.cs
Normal file
122
Yavsc/Controllers/FormsController.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using Microsoft.Data.Entity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Forms;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
public class FormsController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public FormsController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Forms
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(await _context.Form.ToListAsync());
|
||||
}
|
||||
|
||||
// GET: Forms/Details/5
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(form);
|
||||
}
|
||||
|
||||
// GET: Forms/Create
|
||||
public IActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Forms/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Create(Form form)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Form.Add(form);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(form);
|
||||
}
|
||||
|
||||
// GET: Forms/Edit/5
|
||||
public async Task<IActionResult> Edit(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
return View(form);
|
||||
}
|
||||
|
||||
// POST: Forms/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Edit(Form form)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_context.Update(form);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
return View(form);
|
||||
}
|
||||
|
||||
// GET: Forms/Delete/5
|
||||
[ActionName("Delete")]
|
||||
public async Task<IActionResult> Delete(string id)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
if (form == null)
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
return View(form);
|
||||
}
|
||||
|
||||
// POST: Forms/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
Form form = await _context.Form.SingleAsync(m => m.Id == id);
|
||||
_context.Form.Remove(form);
|
||||
await _context.SaveChangesAsync();
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
@ -89,7 +89,7 @@ namespace Yavsc.Controllers
|
||||
return View("Index");
|
||||
}
|
||||
ViewBag.Activities = _context.ActivityItems(null);
|
||||
return View(_context.Performers.Include(p => p.Performer).Where
|
||||
return View("Book",_context.Performers.Include(p => p.Performer).Where
|
||||
(p => p.Active).OrderBy(
|
||||
x => x.MinDailyCost
|
||||
));
|
||||
|
@ -8,6 +8,7 @@ using Yavsc.Models;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.Data.Entity;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
@ -30,7 +31,7 @@ namespace Yavsc.Controllers
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View(DbContext.Activities.OrderByDescending(a=>a.Rate));
|
||||
return View(DbContext.Activities.Include(a=>a.Forms).OrderByDescending(a=>a.Rate));
|
||||
}
|
||||
|
||||
public IActionResult About()
|
||||
|
Reference in New Issue
Block a user