创建视图不从控制器发布create方法 [英] CREATE view does not Post the create method from the controller

查看:103
本文介绍了创建视图不从控制器发布create方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建视图不会发布(或者叫创建方法与模型参数)。

CREATE VIEW

  @model Univita.LtcClaims.Models.EpisodeOfBenefitModel@ {
    ViewBag.Title =创建;
    布局=〜/查看/共享/ _Layout.cshtml
}< H2>创建< / H>@using(Html.BeginForm(NULL,EpisodeOfBenefit,FormMethod.Post)){
    @ Html.ValidationSummary(真)    <&字段集GT;
        <传奇> EpisodeOfBenefitModel< /传说>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.episode_of_benefit_id)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.episode_of_benefit_id)
            @ Html.ValidationMessageFor(型号=> model.episode_of_benefit_id)
        < / DIV>
        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.rfb_id)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.rfb_id)
            @ Html.ValidationMessageFor(型号=> model.rfb_id)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.user_id)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.user_id)
            @ Html.ValidationMessageFor(型号=> model.user_id)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_status_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_status_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_status_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_creation_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_creation_dt)
            @ Html.ValidationMessageFor(型号=> model.eb_creation_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_decision_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_decision_dt)
            @ Html.ValidationMessageFor(型号=> model.eb_decision_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_start_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_start_dt)
            @ Html.ValidationMessageFor(型号=> model.eb_start_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_end_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_end_dt)
            @ Html.ValidationMessageFor(型号=> model.eb_end_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_reassessment_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_reassessment_dt)
            @ Html.ValidationMessageFor(型号=> model.eb_reassessment_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_revocation_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_revocation_dt)
            @ Html.ValidationMessageFor(型号=> model.eb_revocation_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_last_extension_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_last_extension_dt)
            @ Html.ValidationMessageFor(型号=> model.eb_last_extension_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_ambulation_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_ambulation_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_ambulation_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_bathing_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_bathing_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_bathing_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_dressing_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_dressing_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_dressing_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_feeding_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_feeding_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_feeding_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_incontinence_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_incontinence_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_incontinence_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_toileting_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_toileting_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_toileting_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_transferring_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_transferring_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_transferring_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_abusive_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_abusive_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_abusive_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_bizarre_hygiene_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_bizarre_hygiene_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_bizarre_hygiene_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_poor_judgement_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_poor_judgement_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_poor_judgement_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_wandering_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_wandering_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_wandering_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_other_behavior_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_other_behavior_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_other_behavior_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_cognitive_imp_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_cognitive_imp_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_cognitive_imp_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_complex_unstable_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_complex_unstable_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_complex_unstable_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_medicare_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_medicare_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_medicare_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_other_ins_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_other_ins_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_other_ins_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_living_arr_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_living_arr_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_living_arr_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_ra_type_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_ra_type_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_ra_type_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_ra_ltr_rcv_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_ra_ltr_rcv_dt)
            @ Html.ValidationMessageFor(型号=> model.eb_ra_ltr_rcv_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_status_rsn_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_status_rsn_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_status_rsn_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_medication_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_medication_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_medication_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_reviewer_user_id)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_reviewer_user_id)
            @ Html.ValidationMessageFor(型号=> model.eb_reviewer_user_id)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.last_mod_dt)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.last_mod_dt)
            @ Html.ValidationMessageFor(型号=> model.last_mod_dt)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.last_mod_by_user_id)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.last_mod_by_user_id)
            @ Html.ValidationMessageFor(型号=> model.last_mod_by_user_id)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_wound_care_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_wound_care_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_wound_care_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_med_mgmt_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_med_mgmt_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_med_mgmt_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_vent_dependent_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_vent_dependent_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_vent_dependent_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_adl_dependent_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_adl_dependent_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_adl_dependent_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_diabeties_mgmt_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_diabeties_mgmt_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_diabeties_mgmt_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_spvn_for_safety_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_spvn_for_safety_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_spvn_for_safety_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_not_listed_cd)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_not_listed_cd)
            @ Html.ValidationMessageFor(型号=> model.eb_not_listed_cd)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.icd9_ code)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.icd9_ code)
            @ Html.ValidationMessageFor(型号=> model.icd9_ code)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.icd9_rcd_type)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.icd9_rcd_type)
            @ Html.ValidationMessageFor(型号=> model.icd9_rcd_type)
        < / DIV>        < D​​IV CLASS =编辑标记>
            @ Html.LabelFor(型号=> model.eb_living_arr_other_text)
        < / DIV>
        < D​​IV CLASS =主编场>
            @ Html.EditorFor(型号=> model.eb_living_arr_other_text)
            @ Html.ValidationMessageFor(型号=> model.eb_living_arr_other_text)
        < / DIV>        &所述p为H.;
            <输入类型=提交值=创建/>
        &所述; / P>
    < /字段集>
}< D​​IV>
    @ Html.ActionLink(返回目录,索引)
< / DIV>@section脚本{
    @ Scripts.Render(〜/包/ jqueryval)
}< BR />

控制器

 使用系统;
System.Collections中使用;
使用System.Collections.Generic;
使用System.Data这;
使用System.Data.Objects;
使用System.Linq的;
使用的System.Web;
使用System.Web.Mvc;
使用Univita.LtcClaims.Dal;
使用Univita.LtcClaims.Models;
使用AutoMapper;命名空间Univita.LtcClaims.Controllers
{
    公共类EpisodeOfBenefitController:控制器
    {       静态只读DbEntities的DbContext = DbContextFactory.GetContext();
       只读GenericRepository _repository =新GenericRepository(的DbContext);
       公共IEnumerable的< EpisodeOfBenefit> Eobresults = NULL;        //私人DbEntities的DbContext =新DbEntities();
        //
        // GET:/ EpisodeOfBenefit /        公众的ActionResult指数()
        {
            // Eobresults = dbContext.episode_of_benefit.Where(W => w.rfb_id == 3721130);
            Eobresults = _repository.Find< EpisodeOfBenefit>(W => w.RfbId == 3721130);
            返回查看(Eobresults);
        }        //
        // GET:/ EpisodeOfBenefit /详细资料/ 5        公众的ActionResult详细信息(INT ID)
        {
            返回查看();
        }        //
        // GET:/ EpisodeOfBenefit /创建        [HTTPGET]
        公众的ActionResult的Create()
        {            // Eobresults = _repository.GetQuery< EpisodeOfBenefit>()ToArray的()。
            // Eobresults = _repository.Find< EpisodeOfBenefit>(W => w.RfbId == 3721130);
            //Mapper.CreateMap<EpisodeOfBenefit,EpisodeOfBenefitModel&GT;();
            //Mapper.Map(EpisodeOfBenefit [],EpisodeOfBenefitModel [])();
            返回查看();
        }        //
        // POST:/ EpisodeOfBenefit /创建        [HttpPost]
        //公众的ActionResult创建(的FormCollection集合)
        公众的ActionResult创建(EpisodeOfBenefitModel episodeOfBenefit)
        {
            尝试
            {
                // TODO:添加插入逻辑这里
                _repository.Add(episodeOfBenefit);
                _repository.SaveChanges();
                返回RedirectToAction(「指数」);
            }
            抓住
            {
                返回查看(episodeOfBenefit);
            }
        }

模型

 使用系统;
使用System.Collections.Generic;
使用System.ComponentModel.DataAnnotations;
使用System.Linq的;
使用的System.Web;命名空间Univita.LtcClaims.Models
{
    公共类EpisodeOfBenefitModel
    {            //this.eob_service_detail_paid_day =新的HashSet&LT; eob_service_detail_paid_day&GT;();
            //this.plan_of_care =新的HashSet&LT; plan_of_care&GT;();
        [键]
        公众诠释episode_of_benefit_id {搞定;组; }
        公众诠释rfb_id {搞定;组; }
        公共字符串USER_ID {搞定;组; }
        公共短eb_status_cd {搞定;组; }
        公众的DateTime eb_creation_dt {搞定;组; }
        公众的DateTime eb_decision_dt {搞定;组; }
        公众的DateTime eb_start_dt {搞定;组; }
        公众的DateTime eb_end_dt {搞定;组; }
        公众的DateTime eb_reassessment_dt {搞定;组; }
        公众的DateTime eb_revocation_dt {搞定;组; }
        公众的DateTime eb_last_extension_dt {搞定;组; }
        公共短eb_adl_ambulation_cd {搞定;组; }
        公共短eb_adl_bathing_cd {搞定;组; }
        公共短eb_adl_dressing_cd {搞定;组; }
        公共短eb_adl_feeding_cd {搞定;组; }
        公共短eb_adl_incontinence_cd {搞定;组; }
        公共短eb_adl_toileting_cd {搞定;组; }
        公共短eb_adl_transferring_cd {搞定;组; }
        公共短eb_abusive_cd {搞定;组; }
        公共短eb_bizarre_hygiene_cd {搞定;组; }
        公共短eb_poor_judgement_cd {搞定;组; }
        公共短eb_wandering_cd {搞定;组; }
        公共短eb_other_behavior_cd {搞定;组; }
        公共短eb_cognitive_imp_cd {搞定;组; }
        公共短eb_complex_unstable_cd {搞定;组; }
        公共短eb_medicare_cd {搞定;组; }
        公共短eb_other_ins_cd {搞定;组; }
        公共短eb_living_arr_cd {搞定;组; }
        公共短eb_ra_type_cd {搞定;组; }
        公众的DateTime eb_ra_ltr_rcv_dt {搞定;组; }
        公共短eb_status_rsn_cd {搞定;组; }
        公共短eb_adl_medication_cd {搞定;组; }
        公共字符串eb_reviewer_user_id {搞定;组; }
        公众的DateTime last_mod_dt {搞定;组; }
        公共字符串last_mod_by_user_id {搞定;组; }
        公共短eb_wound_care_cd {搞定;组; }
        公共短eb_med_mgmt_cd {搞定;组; }
        公共短eb_vent_dependent_cd {搞定;组; }
        公共短eb_adl_dependent_cd {搞定;组; }
        公共短eb_diabeties_mgmt_cd {搞定;组; }
        公共短eb_spvn_for_safety_cd {搞定;组; }
        公共短eb_not_listed_cd {搞定;组; }
        公共字符串icd9_ code {搞定;组; }
        公共字符串icd9_rcd_type {搞定;组; }
        公共字符串eb_living_arr_other_text {搞定;组; }        //公共虚拟eb_living_arr eb_living_arr {搞定;组; }
        //公共虚拟的ICollection&LT; eob_service_detail_paid_day&GT; eob_service_detail_paid_day {搞定;组; }
        //公共虚拟request_for_benefit request_for_benefit {搞定;组; }
        //公共虚拟的ICollection&LT; plan_of_care&GT; plan_of_care {搞定;组; }
    }
}


解决方案

您应该更改

  @using(Html.BeginForm(NULL,EpisodeOfBenefit,FormMethod.Post))

  @using(Html.BeginForm(创建,EpisodeOfBenefit,FormMethod.Post))

在code,您尝试发布到行动名称为null。

The create view does not post (or call the create method with the model parameter).

CREATE VIEW

@model Univita.LtcClaims.Models.EpisodeOfBenefitModel

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Create</h2>

@using (Html.BeginForm(null, "EpisodeOfBenefit",FormMethod.Post)) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>EpisodeOfBenefitModel</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.episode_of_benefit_id)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.episode_of_benefit_id)
            @Html.ValidationMessageFor(model => model.episode_of_benefit_id)
        </div>


        <div class="editor-label">
            @Html.LabelFor(model => model.rfb_id)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.rfb_id)
            @Html.ValidationMessageFor(model => model.rfb_id)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.user_id)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.user_id)
            @Html.ValidationMessageFor(model => model.user_id)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_status_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_status_cd)
            @Html.ValidationMessageFor(model => model.eb_status_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_creation_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_creation_dt)
            @Html.ValidationMessageFor(model => model.eb_creation_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_decision_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_decision_dt)
            @Html.ValidationMessageFor(model => model.eb_decision_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_start_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_start_dt)
            @Html.ValidationMessageFor(model => model.eb_start_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_end_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_end_dt)
            @Html.ValidationMessageFor(model => model.eb_end_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_reassessment_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_reassessment_dt)
            @Html.ValidationMessageFor(model => model.eb_reassessment_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_revocation_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_revocation_dt)
            @Html.ValidationMessageFor(model => model.eb_revocation_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_last_extension_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_last_extension_dt)
            @Html.ValidationMessageFor(model => model.eb_last_extension_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_ambulation_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_ambulation_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_ambulation_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_bathing_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_bathing_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_bathing_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_dressing_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_dressing_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_dressing_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_feeding_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_feeding_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_feeding_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_incontinence_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_incontinence_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_incontinence_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_toileting_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_toileting_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_toileting_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_transferring_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_transferring_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_transferring_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_abusive_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_abusive_cd)
            @Html.ValidationMessageFor(model => model.eb_abusive_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_bizarre_hygiene_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_bizarre_hygiene_cd)
            @Html.ValidationMessageFor(model => model.eb_bizarre_hygiene_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_poor_judgement_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_poor_judgement_cd)
            @Html.ValidationMessageFor(model => model.eb_poor_judgement_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_wandering_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_wandering_cd)
            @Html.ValidationMessageFor(model => model.eb_wandering_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_other_behavior_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_other_behavior_cd)
            @Html.ValidationMessageFor(model => model.eb_other_behavior_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_cognitive_imp_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_cognitive_imp_cd)
            @Html.ValidationMessageFor(model => model.eb_cognitive_imp_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_complex_unstable_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_complex_unstable_cd)
            @Html.ValidationMessageFor(model => model.eb_complex_unstable_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_medicare_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_medicare_cd)
            @Html.ValidationMessageFor(model => model.eb_medicare_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_other_ins_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_other_ins_cd)
            @Html.ValidationMessageFor(model => model.eb_other_ins_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_living_arr_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_living_arr_cd)
            @Html.ValidationMessageFor(model => model.eb_living_arr_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_ra_type_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_ra_type_cd)
            @Html.ValidationMessageFor(model => model.eb_ra_type_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_ra_ltr_rcv_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_ra_ltr_rcv_dt)
            @Html.ValidationMessageFor(model => model.eb_ra_ltr_rcv_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_status_rsn_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_status_rsn_cd)
            @Html.ValidationMessageFor(model => model.eb_status_rsn_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_medication_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_medication_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_medication_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_reviewer_user_id)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_reviewer_user_id)
            @Html.ValidationMessageFor(model => model.eb_reviewer_user_id)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.last_mod_dt)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.last_mod_dt)
            @Html.ValidationMessageFor(model => model.last_mod_dt)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.last_mod_by_user_id)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.last_mod_by_user_id)
            @Html.ValidationMessageFor(model => model.last_mod_by_user_id)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_wound_care_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_wound_care_cd)
            @Html.ValidationMessageFor(model => model.eb_wound_care_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_med_mgmt_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_med_mgmt_cd)
            @Html.ValidationMessageFor(model => model.eb_med_mgmt_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_vent_dependent_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_vent_dependent_cd)
            @Html.ValidationMessageFor(model => model.eb_vent_dependent_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_adl_dependent_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_adl_dependent_cd)
            @Html.ValidationMessageFor(model => model.eb_adl_dependent_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_diabeties_mgmt_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_diabeties_mgmt_cd)
            @Html.ValidationMessageFor(model => model.eb_diabeties_mgmt_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_spvn_for_safety_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_spvn_for_safety_cd)
            @Html.ValidationMessageFor(model => model.eb_spvn_for_safety_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_not_listed_cd)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_not_listed_cd)
            @Html.ValidationMessageFor(model => model.eb_not_listed_cd)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.icd9_code)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.icd9_code)
            @Html.ValidationMessageFor(model => model.icd9_code)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.icd9_rcd_type)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.icd9_rcd_type)
            @Html.ValidationMessageFor(model => model.icd9_rcd_type)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.eb_living_arr_other_text)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.eb_living_arr_other_text)
            @Html.ValidationMessageFor(model => model.eb_living_arr_other_text)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}  <br/>  

CONTROLLER

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Objects;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Univita.LtcClaims.Dal;
using Univita.LtcClaims.Models;
using AutoMapper;

namespace Univita.LtcClaims.Controllers
{
    public class EpisodeOfBenefitController : Controller
    {

       static readonly DbEntities DbContext = DbContextFactory.GetContext();
       readonly GenericRepository _repository = new GenericRepository(DbContext);
       public IEnumerable<EpisodeOfBenefit> Eobresults = null; 

        //private DbEntities dbContext = new DbEntities();
        //
        // GET: /EpisodeOfBenefit/

        public ActionResult Index()
        {
            //Eobresults = dbContext.episode_of_benefit.Where(w => w.rfb_id == 3721130);
            Eobresults = _repository.Find<EpisodeOfBenefit>(w => w.RfbId == 3721130);
            return View(Eobresults);
        }

        //
        // GET: /EpisodeOfBenefit/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /EpisodeOfBenefit/Create

        [HttpGet]
        public ActionResult Create()
        {

            //Eobresults = _repository.GetQuery<EpisodeOfBenefit>().ToArray();
            //Eobresults = _repository.Find<EpisodeOfBenefit>(w => w.RfbId == 3721130);
            //Mapper.CreateMap<EpisodeOfBenefit, EpisodeOfBenefitModel>();
            //Mapper.Map(EpisodeOfBenefit[], EpisodeOfBenefitModel[])();
            return View();
        }

        //
        // POST: /EpisodeOfBenefit/Create

        [HttpPost]
        //public ActionResult Create(FormCollection collection)
        public ActionResult Create(EpisodeOfBenefitModel episodeOfBenefit)
        {
            try
            {
                // TODO: Add insert logic here
                _repository.Add(episodeOfBenefit);
                _repository.SaveChanges();
                return RedirectToAction("Index");
            }
            catch
            {
                return View(episodeOfBenefit);
            }
        }

MODEL

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace Univita.LtcClaims.Models
{
    public class EpisodeOfBenefitModel
    {

            //this.eob_service_detail_paid_day = new HashSet<eob_service_detail_paid_day>();
            //this.plan_of_care = new HashSet<plan_of_care>();


        [Key]
        public int episode_of_benefit_id { get; set; }
        public int rfb_id { get; set; }
        public string user_id { get; set; }
        public short eb_status_cd { get; set; }
        public DateTime eb_creation_dt { get; set; }
        public DateTime eb_decision_dt { get; set; }
        public DateTime eb_start_dt { get; set; }
        public DateTime eb_end_dt { get; set; }
        public DateTime eb_reassessment_dt { get; set; }
        public DateTime eb_revocation_dt { get; set; }
        public DateTime eb_last_extension_dt { get; set; }
        public short eb_adl_ambulation_cd { get; set; }
        public short eb_adl_bathing_cd { get; set; }
        public short eb_adl_dressing_cd { get; set; }
        public short eb_adl_feeding_cd { get; set; }
        public short eb_adl_incontinence_cd { get; set; }
        public short eb_adl_toileting_cd { get; set; }
        public short eb_adl_transferring_cd { get; set; }
        public short eb_abusive_cd { get; set; }
        public short eb_bizarre_hygiene_cd { get; set; }
        public short eb_poor_judgement_cd { get; set; }
        public short eb_wandering_cd { get; set; }
        public short eb_other_behavior_cd { get; set; }
        public short eb_cognitive_imp_cd { get; set; }
        public short eb_complex_unstable_cd { get; set; }
        public short eb_medicare_cd { get; set; }
        public short eb_other_ins_cd { get; set; }
        public short eb_living_arr_cd { get; set; }
        public short eb_ra_type_cd { get; set; }
        public DateTime eb_ra_ltr_rcv_dt { get; set; }
        public short eb_status_rsn_cd { get; set; }
        public short eb_adl_medication_cd { get; set; }
        public string eb_reviewer_user_id { get; set; }
        public DateTime last_mod_dt { get; set; }
        public string last_mod_by_user_id { get; set; }
        public short eb_wound_care_cd { get; set; }
        public short eb_med_mgmt_cd { get; set; }
        public short eb_vent_dependent_cd { get; set; }
        public short eb_adl_dependent_cd { get; set; }
        public short eb_diabeties_mgmt_cd { get; set; }
        public short eb_spvn_for_safety_cd { get; set; }
        public short eb_not_listed_cd { get; set; }
        public string icd9_code { get; set; }
        public string icd9_rcd_type { get; set; }
        public string eb_living_arr_other_text { get; set; }

        //public virtual eb_living_arr eb_living_arr { get; set; }
        //public virtual ICollection<eob_service_detail_paid_day> eob_service_detail_paid_day { get; set; }
        //public virtual request_for_benefit request_for_benefit { get; set; }
        //public virtual ICollection<plan_of_care> plan_of_care { get; set; }
    }
}

解决方案

You should change

@using (Html.BeginForm(null, "EpisodeOfBenefit",FormMethod.Post))

To

@using (Html.BeginForm("Create", "EpisodeOfBenefit",FormMethod.Post))

in your code, you try to post to Action with name null.

这篇关于创建视图不从控制器发布create方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆