2015-01-30 05:44:54 +08:00
|
|
|
|
using BuildFeed.Areas.admin.Models.ViewModel;
|
|
|
|
|
using BuildFeed.Models;
|
2015-01-05 06:14:43 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Web;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
|
|
|
|
|
namespace BuildFeed.Areas.admin.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Authorize(Roles = "Administrators")]
|
|
|
|
|
public class metaController : Controller
|
|
|
|
|
{
|
|
|
|
|
// GET: admin/meta
|
|
|
|
|
public ActionResult index()
|
|
|
|
|
{
|
|
|
|
|
var currentItems = from i in MetaItem.Select()
|
|
|
|
|
group i by i.Id.Type into b
|
|
|
|
|
select b;
|
|
|
|
|
|
|
|
|
|
var pendingLabs = MetaItem.SelectUnusedLabs();
|
|
|
|
|
|
2015-01-30 05:44:54 +08:00
|
|
|
|
return View(new MetaListing()
|
|
|
|
|
{
|
|
|
|
|
CurrentItems = from i in MetaItem.Select()
|
|
|
|
|
group i by i.Id.Type into b
|
2015-02-09 23:15:12 +08:00
|
|
|
|
orderby b.Key.ToString()
|
2015-01-30 05:44:54 +08:00
|
|
|
|
select b,
|
|
|
|
|
|
|
|
|
|
NewItems = from i in (from l in MetaItem.SelectUnusedLabs()
|
|
|
|
|
select new MetaItem()
|
|
|
|
|
{
|
|
|
|
|
Id = new MetaItemKey()
|
|
|
|
|
{
|
|
|
|
|
Type = MetaType.Lab,
|
|
|
|
|
Value = l
|
|
|
|
|
}
|
2015-02-09 23:15:12 +08:00
|
|
|
|
}).Concat(from v in MetaItem.SelectUnusedVersions()
|
|
|
|
|
select new MetaItem()
|
|
|
|
|
{
|
|
|
|
|
Id = new MetaItemKey()
|
|
|
|
|
{
|
|
|
|
|
Type = MetaType.Version,
|
|
|
|
|
Value = v
|
|
|
|
|
}
|
|
|
|
|
})
|
2015-01-30 05:44:54 +08:00
|
|
|
|
group i by i.Id.Type into b
|
2015-02-09 23:15:12 +08:00
|
|
|
|
orderby b.Key.ToString()
|
2015-01-30 05:44:54 +08:00
|
|
|
|
select b
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult create(MetaType type, string value)
|
|
|
|
|
{
|
|
|
|
|
return View(new MetaItem() { Id = new MetaItemKey() { Type = type, Value = value } });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult create(MetaItem meta)
|
|
|
|
|
{
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
MetaItem.Insert(meta);
|
|
|
|
|
return RedirectToAction("index");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return View(meta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ActionResult edit(MetaType type, string value)
|
|
|
|
|
{
|
|
|
|
|
return View("create", MetaItem.SelectById(new MetaItemKey() { Type = type, Value = value }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public ActionResult edit(MetaItem meta)
|
|
|
|
|
{
|
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
|
{
|
|
|
|
|
MetaItem.Update(meta);
|
|
|
|
|
return RedirectToAction("index");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return View("create", meta);
|
2015-01-05 06:14:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|