137 lines
4.7 KiB
C#
137 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.Entity;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Church.Net.DAL.EF;
|
|
using Church.Net.Entity;
|
|
|
|
namespace Chruch.Net.Areas.dashboard.Controllers
|
|
{
|
|
public class HappinessBESTsController : Controller
|
|
{
|
|
private ChurchNetContext db = new ChurchNetContext();
|
|
|
|
// GET: dashboard/HappinessBESTs
|
|
public ActionResult Index(string groupId)
|
|
{
|
|
var happinessBESTs = db.HappinessBESTs.Include(h => h.HappinessGroup).Where(h=>h.GroupId==groupId);
|
|
return View(happinessBESTs.ToList());
|
|
}
|
|
|
|
// GET: dashboard/HappinessBESTs/Details/5
|
|
public ActionResult Details(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
HappinessBEST happinessBEST = db.HappinessBESTs.Find(id);
|
|
if (happinessBEST == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(happinessBEST);
|
|
}
|
|
|
|
// GET: dashboard/HappinessBESTs/Create
|
|
public ActionResult Create(string id)
|
|
{
|
|
ViewBag.GroupId = new SelectList(db.HappinessGroups, "GroupId", "Name", id);
|
|
HappinessBEST happinessBEST = new HappinessBEST();
|
|
happinessBEST.BestId = Church.Net.Utility.Format.Get33BaseGuid();
|
|
happinessBEST.GroupId = id;
|
|
return View(happinessBEST);
|
|
}
|
|
|
|
// POST: dashboard/HappinessBESTs/Create
|
|
// 若要免於過量張貼攻擊,請啟用想要繫結的特定屬性,如需
|
|
// 詳細資訊,請參閱 https://go.microsoft.com/fwlink/?LinkId=317598。
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Create([Bind(Include = "BestId,GroupId,Name,Email,Phone")] HappinessBEST happinessBEST)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
db.HappinessBESTs.Add(happinessBEST);
|
|
db.SaveChanges();
|
|
return RedirectToAction("Details", "HappinessGroups", new { id= happinessBEST.GroupId});
|
|
}
|
|
|
|
ViewBag.GroupId = new SelectList(db.HappinessGroups, "GroupId", "Name", happinessBEST.GroupId);
|
|
return View(happinessBEST);
|
|
}
|
|
|
|
// GET: dashboard/HappinessBESTs/Edit/5
|
|
public ActionResult Edit(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
HappinessBEST happinessBEST = db.HappinessBESTs.Find(id);
|
|
if (happinessBEST == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
ViewBag.GroupId = new SelectList(db.HappinessGroups, "GroupId", "Name", happinessBEST.GroupId);
|
|
return View(happinessBEST);
|
|
}
|
|
|
|
// POST: dashboard/HappinessBESTs/Edit/5
|
|
// 若要免於過量張貼攻擊,請啟用想要繫結的特定屬性,如需
|
|
// 詳細資訊,請參閱 https://go.microsoft.com/fwlink/?LinkId=317598。
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Edit([Bind(Include = "BestId,GroupId,Name,Email,Phone")] HappinessBEST happinessBEST)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
db.Entry(happinessBEST).State = EntityState.Modified;
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
ViewBag.GroupId = new SelectList(db.HappinessGroups, "GroupId", "Name", happinessBEST.GroupId);
|
|
return View(happinessBEST);
|
|
}
|
|
|
|
// GET: dashboard/HappinessBESTs/Delete/5
|
|
public ActionResult Delete(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
HappinessBEST happinessBEST = db.HappinessBESTs.Find(id);
|
|
if (happinessBEST == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(happinessBEST);
|
|
}
|
|
|
|
// POST: dashboard/HappinessBESTs/Delete/5
|
|
[HttpPost, ActionName("Delete")]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult DeleteConfirmed(string id)
|
|
{
|
|
HappinessBEST happinessBEST = db.HappinessBESTs.Find(id);
|
|
db.HappinessBESTs.Remove(happinessBEST);
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
db.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
}
|