Пример #1
0
 /// <summary>
 /// Save the specified location.
 /// </summary>
 /// <param name="location">The location to be saved.</param>
 /// <returns>Number of affected rows.</returns>
 public static int Save(Location location)
 {
     using (SqlConnection connection = SamenSterkerDB.GetConnection())
     {
         int rowsAffected = connection.Execute(
             sql: isNew(location) ? insertCommand : updateCommand,
             param: location
         );
         //SetIdentity<int>(connection, id => subCategory.Id = id);
         return rowsAffected;
     }
 }
Пример #2
0
        /// <summary>
        /// Delete the specified location.
        /// </summary>
        /// <param name="location">The location to be deleted.</param>
        /// <returns>Number of affected rows.</returns>
        public static int Delete(Location location)
        {
            const string deleteCommand =
                  "DELETE FROM Location WHERE Id = @LocationId";

            using (SqlConnection connection = SamenSterkerDB.GetConnection())
            {
                return connection.Execute(
                    sql: deleteCommand,
                    param: location
                );
            }
        }
Пример #3
0
 private static Reservation ReservationMapper(
     Reservation reservation, Location location, Company company)
 {
     reservation.Location = location;
     reservation.Company = company;
     return reservation;
 }
Пример #4
0
 private static bool isNew(Location location)
 {
     return location.Id == 0;
 }