예제 #1
0
        /// <summary>
        /// Inserts state or territory information into the underlying data source.
        /// </summary>
        /// <param name="abbreviatedName">The state or territory name in abbreviated form.</param>
        /// <param name="isDeleted">Specifies whether the offence category is flagged as deleted.</param>
        /// <param name="isVisible">Specifies whether the offence category is flagged as visible.</param>
        /// <param name="name">The name of the state or territory.</param>
        /// <returns></returns>
        public int AddState(string abbreviatedName, bool isDeleted, bool isVisible, string name)
        {
            int id = 0;

            using (SqlConnection sqlConnection = SqlConnectionFactory.NewSqlConnetion())
            {
                id = (int)SqlMapper
                     .Query(sqlConnection, LocationSpAddState, new { AbbreviatedName = abbreviatedName, IsDeleted = isDeleted, IsVisible = isVisible, Name = name }, commandType: CommandType.StoredProcedure)
                     .Select(m => m.NewID)
                     .Single();
            }

            return(id);
        }
예제 #2
0
        /// <summary>
        /// Selects state or territory information from the underlying data source.
        /// </summary>
        /// <param name="id">The ID of the corresponding state or territory information.</param>
        /// <returns>Returns a State object representing the result of the operation.</returns>
        public State GetStateByID(int id)
        {
            State state = null;

            using (SqlConnection sqlConnection = SqlConnectionFactory.NewSqlConnetion())
            {
                state = SqlMapper
                        .Query(sqlConnection, "Location.spGetStateByID", new { ID = id }, commandType: CommandType.StoredProcedure)
                        .Select(m => new State(m.AbbreviatedName, m.DateCreatedUtc, m.DateUpdatedUtc, m.ID, m.IsDeleted, m.IsVisible, m.Name))
                        .FirstOrDefault();
            }

            return(state);
        }
예제 #3
0
        /// <summary>
        /// Selects all state or territory information from the underlying data source.
        /// </summary>
        /// <returns>Returns a list of State objects representing the result of the operation.</returns>
        public List <State> GetStates()
        {
            List <State> states = null;

            using (SqlConnection sqlConnection = SqlConnectionFactory.NewSqlConnetion())
            {
                states = SqlMapper
                         .Query(sqlConnection, "Location.spGetState", commandType: CommandType.StoredProcedure)
                         .Select(m => new State(m.AbbreviatedName, m.DateCreatedUtc, m.DateUpdatedUtc, m.ID, m.IsDeleted, m.IsVisible, m.Name))
                         .ToList();
            }

            return(states);
        }
예제 #4
0
 /// <summary>
 /// Updates crime information in the underlying data source.
 /// </summary>
 /// <param name="id">The ID of the associated crime.</param>
 /// <param name="localGovernmentAreaID">Specified the ID of the associated local government area.</param>
 /// <param name="offenceID">Specifies the ID of the associated offence.</param>
 /// <param name="count">Specifies the count of the offences.</param>
 /// <param name="month">Specifies the month of the crime.</param>
 /// <param name="year">Specifies the year of the crime.</param>
 /// <param name="isDeleted">Specifies whether the crime information is flagged as deleted.</param>
 /// <param name="isVisible">Specifies whether the crime information is flagged as visible.</param>
 public void UpdateCrime(int id, int localGovernmentAreaID, int offenceID, int count, int month, int year, bool isDeleted, bool isVisible)
 {
     using (SqlConnection sqlConnection = SqlConnectionFactory.NewSqlConnetion())
     {
         SqlMapper.Execute(sqlConnection, CrimeSpUpdateCrime, new
         {
             ID = id,
             LocalGovernmentAreaID = localGovernmentAreaID,
             OffenceID             = offenceID,
             Count     = count,
             Month     = month,
             Year      = year,
             IsDeleted = isDeleted,
             IsVisible = isVisible,
         },
                           commandType: CommandType.StoredProcedure);
     }
 }