创建视图不会发布(或使用模型参数调用create方法)。
@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/>
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);
}
}
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; }
}
}
答案 0 :(得分:2)
你应该改变
@using (Html.BeginForm(null, "EpisodeOfBenefit",FormMethod.Post))
要
@using (Html.BeginForm("Create", "EpisodeOfBenefit",FormMethod.Post))
在您的代码中,您尝试发布名为null的Action。