/// <summary> /// Delete the specified Step Type. /// </summary> /// <param name="stepTypeId"></param> private void DeleteStepType(int stepTypeId) { var rockContext = this.GetDataContext(); var stepTypeService = new StepTypeService(rockContext); var stepType = stepTypeService.Get(stepTypeId); if (stepType == null) { mdGridWarning.Show("This item could not be found.", ModalAlertType.Information); return; } string errorMessage; if (!stepTypeService.CanDelete(stepType, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } stepTypeService.Delete(stepType); rockContext.SaveChanges(); BindGrid(); }
/// <summary> /// Gets the specified <see cref="StepType"/> by Guid. /// </summary> /// <param name="stepTypeGuid">The Guid of the <see cref="StepType"/>.</param> /// <returns>A <see cref="StepType"/> or null.</returns> private StepType GetStepType(Guid?stepTypeGuid) { if (!stepTypeGuid.HasValue || stepTypeGuid.Value == Guid.Empty) { return(null); } using (var rockContext = new RockContext()) { var stepTypeService = new StepTypeService(rockContext); return(stepTypeService.Get(stepTypeGuid.Value)); } }