C# 使用umbraco mvc 5在数据库中插入数据

C# 使用umbraco mvc 5在数据库中插入数据,c#,asp.net-mvc-4,umbraco,C#,Asp.net Mvc 4,Umbraco,我试图将表单中输入的数据存储到数据库表中,但它根本不起作用,这是模型和控制器,有人想看看,使用mvc 5和umbraco [TableName("staffOnGoingTraining")] [PrimaryKey("id")] public class CreateEmployeeViewModel { [HiddenInput(DisplayValue = false)] public int id { get; set; } [Require

我试图将表单中输入的数据存储到数据库表中,但它根本不起作用,这是模型和控制器,有人想看看,使用mvc 5和umbraco

[TableName("staffOnGoingTraining")]  
[PrimaryKey("id")]  
public class CreateEmployeeViewModel    
{
    [HiddenInput(DisplayValue = false)]  
    public int id { get; set; }

    [Required]
    [Display(Name = "Training Name")]
    public string TrainingName { get; set; }
    [Required]
    [Display(Name = "Expected Cost")]
    public string TrainingCost { get; set; }
    [Display(Name = "Start Date")]
    public DateTime TrainingStartDate { get; set; }
    [Display(Name = "Expected Completion Date")]
    [UIHint("NullableDateTime")]
    public DateTime TrainingExpires { get; set; }
}

public class CreateEmployeeViewController : SurfaceController
{

    [HttpPost]
    public ActionResult AddEmployee(CreateEmployeeViewModel viewModel)
    {

        if (Utils.staffDetail.accessLevel > accessLevel.admin)
        {
            return Content("You are not authorized to edit this information");
        }

        if (ModelState.IsValid)
        {
            var db = ApplicationContext.DatabaseContext.Database;
            var sql = new Umbraco.Core.Persistence.Sql();
            db.Insert(viewModel);
            return PartialView("_Create", viewModel);
        }

        return Content("Thank you, your changes have been saved");

    }
}

“它根本不起作用”你能详细解释一下吗?你有什么错误吗?您是否在控制器中一步一步地调试操作?
它根本不工作
这意味着什么?你有什么错误吗?什么错误?调试后您的发现是什么?