public ActionResult OffenceCategory(uint id) { OffenceCategoryModel offenceCategoryModel = null; OffenceCategory offenceCategory = DataProvider.OffenceCategoryRepository.GetOffenceCategoryByID((int)(id)); if (offenceCategory != null) { offenceCategoryModel = new OffenceCategoryModel(offenceCategory.DateCreatedUtc, offenceCategory.DateUpdatedUtc, offenceCategory.ID, offenceCategory.IsDeleted, offenceCategory.IsVisible, offenceCategory.Name); } return(View(offenceCategoryModel)); }
/// <summary> /// Selects offence category from the underlying data source. /// </summary> /// <param name="id">The ID of the associated offence category.</param> /// <returns>Returns an OffenceCategory object representing the result of the operation.</returns> public OffenceCategory GetOffenceCategoryByID(int id) { OffenceCategory offenceCategory = null; using (SqlConnection sqlConnection = SqlConnectionFactory.NewSqlConnetion()) { offenceCategory = SqlMapper .Query(sqlConnection, CrimeSpGetOffenceCategoryByID, new { ID = id }, commandType: CommandType.StoredProcedure) .Select(m => new OffenceCategory(m.DateCreatedUtc, m.DateUpdatedUtc, m.ID, m.IsDeleted, m.IsVisible, m.Name)) .FirstOrDefault(); } return(offenceCategory); }
/// <summary> /// Checks the database for OffenceCategory records based on a specified ID value. /// </summary> /// <param name="value">The ID value for the Offence record.</param> /// <returns>true if the Offence exists; true if the value argument was null; otherwise false.</returns> public override bool IsValid(object value) { bool isValid = false; if (value != null) { int id = 0; if (Int32.TryParse(value.ToString(), out id) == true) { OffenceCategory localGovernmentArea = DataProvider.OffenceCategoryRepository.GetOffenceCategoryByID(id); isValid = (localGovernmentArea != null); } } else { isValid = true; } return(isValid); }