Witam!
Piszę dość duży system CMS przy użyciu ASP.NET MVC5
Tworzę artykuł, który dodaje mi się do bazy.
Do tego artykułu chcę mieć możliwość dodawania tagów. Do tagów użyłem wtyczki tagIT .NET.
Projekt tworzony przy użyciu EntityFramework i codefirst.
Jak to jakoś fajnie rozwiązać aby te tagi wprowadzane w tagiIT zapisywały się w bazie?
Tak wygląda mój kontroler ResetTag:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ResetProjectMVC5.Models;
namespace ResetProjectMVC5.Controllers
{
public class ResetTagsController : Controller
{
private readonly IResetTagRepository resettagRepository;
// If you are using Dependency Injection, you can delete the following constructor
public ResetTagsController() : this(new ResetTagRepository())
{
}
public ResetTagsController(IResetTagRepository resettagRepository)
{
this.resettagRepository = resettagRepository;
}
//
// GET: /ResetTags/
public ViewResult Index()
{
return View(resettagRepository.All);
}
//
// GET: /ResetTags/Details/5
public ViewResult Details(int id)
{
return View(resettagRepository.Find(id));
}
//
// GET: /ResetTags/Create
public ActionResult Create()
{
return View();
}
//
// POST: /ResetTags/Create
[HttpPost]
public ActionResult Create(ResetTag resettag)
{
if (ModelState.IsValid) {
resettagRepository.InsertOrUpdate(resettag);
resettagRepository.Save();
return RedirectToAction("Index");
} else {
return View();
}
}
//
// GET: /ResetTags/Edit/5
public ActionResult Edit(int id)
{
return View(resettagRepository.Find(id));
}
//
// POST: /ResetTags/Edit/5
[HttpPost]
public ActionResult Edit(ResetTag resettag)
{
if (ModelState.IsValid) {
resettagRepository.InsertOrUpdate(resettag);
resettagRepository.Save();
return RedirectToAction("Index");
} else {
return View();
}
}
//
// GET: /ResetTags/Delete/5
public ActionResult Delete(int id)
{
return View(resettagRepository.Find(id));
}
//
// POST: /ResetTags/Delete/5
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
resettagRepository.Delete(id);
resettagRepository.Save();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
if (disposing) {
resettagRepository.Dispose();
}
base.Dispose(disposing);
}
}
}
Bardzo proszę o pomoc.