Dodawanie tagów do bazy + ASP.NET MVC 5 + EF

0

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?
user image

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.

0

Najprostsze rozwiązanie - weź zawartość tego TextBoxa i ją zapisz do bazy.
Słabo opisałeś problem, coś nie działa, czy co?

0

Już udało mi się dojść do rozwiązania problemu. Możecie zamknąć temat.:)

0

Po prostu źle updatowałem entity object. To duży projekt więc trudno tutaj coś wklejać :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1