MVC5存储库和unitofwork模式

时间:2015-06-04 12:07:18

标签: c# asp.net-mvc razor

我正在尝试实现一个搜索方法:getCompte使用帐号并作为参数但我无法获得响应视图!我不知道错误在哪里

形式:

   @using (Html.BeginForm("SearchCompte", "Compte", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
        {
           @Html.AntiForgeryToken()
           @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
            @Html.Label("NumCompte", new { @class = "col-md-2 control-label" })
               <div class="col-md-3">
                    @Html.TextBox("NumCompte","", new { @class = "form-control", @placeholder = "N° Compte" })
                    @Html.ValidationMessage("NumCompte", "", new { @class = "text-danger" })
                </div>
                @Html.Label("CléRIB", new { @class = "col-md-1 control-label" })
                <div class="col-md-2">
                    @Html.TextBox("CléRIB", "",new { @class = "form-control", @placeholder = "Clé" })
                    @Html.ValidationMessage("CléRIB", "", new { @class = "text-danger" })
                </div>
                <div class=" col-md-2">
                    <input type="submit" name="Search1" value="Search" class="btn btn-primary" />
                </div>
            </div>

控制器:

[HTTPGET]

    public ActionResult SearchCompte()
    {
       //var Compte = new Compte();
        //var cp = service.GetComptes();
        return View();
    }
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult SearchCompte(string NumCompte,string CléRIB)
    {
            try
            {
                long num = Convert.ToInt64(NumCompte);
                var cp = service.GetCompte(num);
                return View(cp);
            }
            catch (Exception)
            {
                ViewBag.Message = "         The account doesn't exist";
                return View();
            } 

    }

0 个答案:

没有答案