本文整理汇总了C#中Race.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Race.Create方法的具体用法?C# Race.Create怎么用?C# Race.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Race
的用法示例。
在下文中一共展示了Race.Create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRace
public ActionResult CreateRace(int id, Race race)
{
ViewData["tournamentID"] = id;
ViewData["tourneyname"] = Tournament.Detail(id).Tournament.TournamentName;
race.EventID = id;
race.Create();
Heat.CreateHeatsForRace(race);
return RedirectToAction("Index", new { id = id });
}
示例2: AddRaceData
public ActionResult AddRaceData(AddEditRaceViewModel vModel)
{
string message = string.Empty;
var authedUser = UserManager.FindById(User.Identity.GetUserId());
var newObj = new Race();
newObj.Name = vModel.NewName;
if (vModel.NewArmsID > 0 && vModel.NewArmsAmount > 0)
{
var arm = DataWrapper.GetOne<InanimateData>(vModel.NewArmsID);
if (arm != null)
newObj.Arms = new Tuple<IInanimateData, short>(arm, vModel.NewArmsAmount);
}
if (vModel.NewLegsID > 0 && vModel.NewLegsAmount > 0)
{
var leg = DataWrapper.GetOne<InanimateData>(vModel.NewLegsID);
if (leg != null)
newObj.Legs = new Tuple<IInanimateData, short>(leg, vModel.NewLegsAmount);
}
if (vModel.NewTorsoId > 0)
{
var torso = DataWrapper.GetOne<InanimateData>(vModel.NewTorsoId);
if (torso != null)
newObj.Torso = torso;
}
if (vModel.NewHeadId > 0)
{
var head = DataWrapper.GetOne<InanimateData>(vModel.NewHeadId);
if (head != null)
newObj.Head = head;
}
if (vModel.NewStartingLocationId > 0)
{
var room = DataWrapper.GetOne<RoomData>(vModel.NewStartingLocationId);
if (room != null)
newObj.StartingLocation = room;
}
if (vModel.NewRecallLocationId > 0)
{
var room = DataWrapper.GetOne<RoomData>(vModel.NewRecallLocationId);
if (room != null)
newObj.EmergencyLocation = room;
}
if (vModel.NewBloodId > 0)
{
var blood = ReferenceWrapper.GetOne<Material>(vModel.NewBloodId);
if (blood != null)
newObj.SanguinaryMaterial = blood;
}
newObj.VisionRange = new Tuple<short, short>(vModel.NewVisionRangeLow, vModel.NewVisionRangeHigh);
newObj.TemperatureTolerance = new Tuple<short, short>(vModel.NewTemperatureToleranceLow, vModel.NewTemperatureToleranceHigh);
newObj.Breathes = (RespiratoryType)vModel.NewBreathes;
newObj.DietaryNeeds = (DietType)vModel.NewDietaryNeeds;
newObj.TeethType = (DamageType)vModel.NewTeethType;
if (vModel.NewExtraPartsId != null)
{
int partIndex = 0;
var bodyBits = new List<Tuple<IInanimateData, short, string>>();
foreach (var id in vModel.NewExtraPartsId)
{
if (id > 0)
{
if (vModel.NewExtraPartsAmount.Count() <= partIndex || vModel.NewExtraPartsName.Count() <= partIndex)
break;
var currentName = vModel.NewExtraPartsName[partIndex];
var currentAmount = vModel.NewExtraPartsAmount[partIndex];
var partObject = DataWrapper.GetOne<InanimateData>(id);
if (partObject != null && currentAmount > 0 && !string.IsNullOrWhiteSpace(currentName))
bodyBits.Add(new Tuple<IInanimateData, short, string>(partObject, currentAmount, currentName));
}
partIndex++;
}
newObj.BodyParts = bodyBits;
}
if (newObj.Create() == null)
message = "Error; Creation failed.";
else
{
//.........这里部分代码省略.........