protected IEnumerable<OccupiedPositionInfo> GetOccupiedPositions () { var division1 = new DivisionInfo { DivisionID = 1 }; var division2 = new DivisionInfo { DivisionID = 2 }; var position11 = new PositionInfo { PositionID = 11, Title = "Director", ShortTitle = "Chief" }; var position12 = new PositionInfo { PositionID = 12, Title = "Manager" }; var position13 = new PositionInfo { PositionID = 13, Title = "Consultant" }; return new List<OccupiedPositionInfo> { new OccupiedPositionInfo { DivisionID = 1, Division = division1, PositionID = 11, Position = position11 }, new OccupiedPositionInfo { DivisionID = 2, Division = division2, PositionID = 12, Position = position12, TitleSuffix = "(main)" }, new OccupiedPositionInfo { DivisionID = 1, Division = division1, PositionID = 13, Position = position13 } }; }
/// <summary> /// Handles Click event for Update button /// </summary> /// <param name='sender'> /// Sender. /// </param> /// <param name='e'> /// Event args. /// </param> protected void buttonUpdate_Click (object sender, EventArgs e) { try { PositionInfo item; // determine if we are adding or updating // ALT: if (Null.IsNull (itemId)) if (!itemId.HasValue) { // add new record item = new PositionInfo (); } else { // update existing record item = ModelContext.Get<PositionInfo> (itemId.Value); } if (item != null) { // fill the object item.Title = txtTitle.Text.Trim (); item.ShortTitle = txtShortTitle.Text.Trim (); item.Weight = TypeUtils.ParseToNullable<int> (txtWeight.Text) ?? 0; item.IsTeacher = checkIsTeacher.Checked; ModelContext.AddOrUpdate (item); ModelContext.SaveChanges (); ModuleController.SynchronizeModule (ModuleId); Response.Redirect (Globals.NavigateURL (), true); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException (this, ex); } }