Что происходит с этой ошибкой?
«Метод расширения должен быть определен в неуниверсальном статическом классе»
Контроллер:
namespace HolidayTracker.Controllers
{
public class HolidayRequestFormsController : Controller
{
private LotusWorksEntities db = new LotusWorksEntities();
// GET: HolidayRequestForms
public ActionResult Index()
{
var holidayRequestForms = db.HolidayRequestForms.Include(h => h.Employee);
return View(holidayRequestForms.ToList());
}
// GET: HolidayRequestForms/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
HolidayRequestForm holidayRequestForm = db.HolidayRequestForms.Find(id);
if (holidayRequestForm == null)
{
return HttpNotFound();
}
return View(holidayRequestForm);
}
// GET: HolidayRequestForms/Create
public ActionResult Create()
{
ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FullName");
return View();
}
// POST: HolidayRequestForms/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "RequestID,EmployeeID,StartDate,FinishDate,HoursTaken,Comments,YearCreated,MonthCreated,DayCreated,YearOfHoliday,Approved")] HolidayRequestForm holidayRequestForm)
{
if (ModelState.IsValid)
{
db.HolidayRequestForms.Add(holidayRequestForm);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FullName", holidayRequestForm.EmployeeID);
return View(holidayRequestForm);
}
// GET: HolidayRequestForms/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
HolidayRequestForm holidayRequestForm = db.HolidayRequestForms.Find(id);
if (holidayRequestForm == null)
{
return HttpNotFound();
}
ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FullName", holidayRequestForm.EmployeeID);
return View(holidayRequestForm);
}
// POST: HolidayRequestForms/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "RequestID,EmployeeID,StartDate,FinishDate,HoursTaken,Comments,YearCreated,MonthCreated,DayCreated,YearOfHoliday,Approved")] HolidayRequestForm holidayRequestForm)
{
if (ModelState.IsValid)
{
db.Entry(holidayRequestForm).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FullName", holidayRequestForm.EmployeeID);
return View(holidayRequestForm);
}
// GET: HolidayRequestForms/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
HolidayRequestForm holidayRequestForm = db.HolidayRequestForms.Find(id);
if (holidayRequestForm == null)
{
return HttpNotFound();
}
return View(holidayRequestForm);
}
// POST: HolidayRequestForms/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
HolidayRequestForm holidayRequestForm = db.HolidayRequestForms.Find(id);
db.HolidayRequestForms.Remove(holidayRequestForm);
db.SaveChanges();
return RedirectToAction("Index");
}
public static MvcHtmlString DisplayWithBreaksFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression)
{
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
var model = html.Encode(metadata.Model).Replace("\r\n", "<br />\r\n");
if (String.IsNullOrEmpty(model))
return MvcHtmlString.Empty;
return MvcHtmlString.Create(model);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}
Я попытался изменить его на статический, но это вызывает больше ошибок во всех моих действиях.
Ошибка3 «Индекс»: невозможно объявить элементы экземпляра в статическом классе
В прошлый раз, когда я закрывал проект, все работало нормально, я просто открыл его, запустил и получил эти ошибки.