/// <summary> /// Deprecated Method for adding a new object to the Races EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRaces(Race race) { base.AddObject("Races", race); }
/// <summary> /// Create a new Race object. /// </summary> /// <param name="raceId">Initial value of the RaceId property.</param> /// <param name="organizationId">Initial value of the OrganizationId property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="genderRestriction">Initial value of the GenderRestriction property.</param> public static Race CreateRace(global::System.Int64 raceId, global::System.Int64 organizationId, global::System.String description, global::System.String genderRestriction) { Race race = new Race(); race.RaceId = raceId; race.OrganizationId = organizationId; race.Description = description; race.GenderRestriction = genderRestriction; return race; }
public ActionResult Create(RaceCreateViewModel model) { if (!db.Organizations.Any(o => o.OrganizationId == model.OrganizationId) || !AccessIsAllowed(model.OrganizationId)) ModelState.AddModelError("Error", "You are unauthorized to create races for this school"); if (ModelState.IsValid) { var race = new Race { OrganizationId = model.OrganizationId, Description = model.Description, StartedOn = model.StartsAtUTC.Value.ToUniversalTime(), Remarks = model.Remarks, GenderRestriction = model.GenderRestriction, CreatedBy = LoggedInUserId, }; db.Races.AddObject(race); TryDBChange(() => db.SaveChanges()); } return PartialView("CreateForm", model); }