本文整理汇总了C#中Area.InjectFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Area.InjectFrom方法的具体用法?C# Area.InjectFrom怎么用?C# Area.InjectFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Area
的用法示例。
在下文中一共展示了Area.InjectFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AreaNewCreate
public ActionResult AreaNewCreate(string countryUrlPart, AreaNewViewModel m)
{
//-- this is a bit hacky to remove the validation required in step 1 and not have it cause out model to be invalid here.
ModelState.Remove("locality");
//-- Double check for duplicate
var existingArea = geoSvc.GetArea(country.ID, m.Name.ToUrlFriendlyString());
if (existingArea != default(Area))
{
ModelState.AddModelError("Name",
string.Format("There is already an area with the name [{0}] in {1} listed in our database, if you are trying to add a city inside a province with the name name e.g. 'New York', change the name to 'New York, New York'",
m.Name, country.Name));
}
if (ModelState.IsValid)
{
var area = new Area();
area.InjectFrom(m);
area.Geo = SqlGeography.Parse(m.WKT);
geoSvc.CreateArea(area);
return Redirect(area.SlugUrl);
}
else
{
InitializeAreaNewViewData(country, (CfType)m.TypeID, new List<Area>());
m.locality = "DuplicateRetry";
return View("AreaNew", m);
}
}