I've created a small Action in my HomeController to get the skills relating to a User, which the puts this into an Array.
public class SkillsVMsController : Controller
{
private NextrungContext db = new NextrungContext();
public ActionResult GetAllKeySkills()
{
string currentUserId = User.Identity.GetUserId();
var user = db.Users.FirstOrDefault(u => u.AspNetId == currentUserId).UserId;
var query1 = (from t in db.SkillRoleUsers
join s in db.Skills on t.SkillId equals s.SkillId
where t.UserId == user
select s.SkillName);
SkillsVM model = new SkillsVM();
model.KeySkills = query1.ToArray();
return View(model);
}
I need this Array to now appear on a page in a TextBox to allow me to apply the Tag-Editor style I have set up.
I was going with something like this, but no dice.
@Html.TextBox("KeySkills",
@Html.Action("GetAllKeySkills", "Home"),
null,
new { htmlAttributes = new { @class = "skills" } })
I've also tried to use a ViewModel (and again as below), but really don't understand how they work.
SkillsVM
namespace NextRung.Models
{
public class SkillsVM
{
[Key]
public Int32 LinkId { get; set; }
public Int32 SkillId { get; set; }
public string SkillName { get; set; }
public string SkillLongDesc { get; set; }
public bool KeySkill { get; set; }
public string Email { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
[DataType(DataType.Date)]
public DateTime DateOfBirth { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string Address3 { get; set; }
public string Address4 { get; set; }
public string Address5 { get; set; }
public string PostCode { get; set; }
public string PhoneMobile { get; set; }
public string PhoneOther { get; set; }
[DisplayFormat(NullDisplayText = "No Summary yet")]
public string Summary { get; set; }
public Int32? RoleId { get; set; }
public Int32? UserId { get; set; }
public Int32? CritVitId { get; set; }
public Int32? VacancyId { get; set; }
public string[] KeySkills { get; set; }
}
}
Any other ideas?
Aucun commentaire:
Enregistrer un commentaire