public class RegionUpdateDbViewModel
{
[Required]
public string RegionName { get; set; }
public int RegionLevel { get; set; }
public Guid ParentRegionId { get; set; }
public bool IsDeleted { get; set; } = false;
//public List<Guid> CountryIDList { get; set; }
public List<CountryViewModel> CountryIDList { get; set; }
public Guid? UserModifiedById { get; set; }
public Guid? UserDeletedById { get; set; }
public DateTime? ModifiedOn { get; set; }
public DateTime? DeletedOn { get; set; }
[Required]
public Guid Id { get; set; }
}
RegionUpdateDbViewModel是区域更新的模型。在Edit.cshtm中,我有一个用于国家列表的下拉列表。
@Html.DropDownListFor(Model => Model.CountryIDList, (SelectList)(ViewBag.selectedCountryList), "Please select", new { @class = "form-control", multiple = "multiple" })
发布时,我还没有从dropswnlist中选择特定的国家。 以下是我的帖子操作。
[HttpPost]
public IActionResult Edit(RegionUpdateDbViewModel region)
{
try
{
var contollerName = this.ControllerContext.RouteData.Values["controller"].ToString();
HttpResponseMessage response = _serviceRepository.PutResponse(contollerName, region);
response.EnsureSuccessStatusCode();
}
catch (Exception ex)
{
}
return RedirectToAction("Index");
}