public State CreateState(State state)
 {
     using (var db = new DataAccess())
     {
         db.CreateStoredProcCommand("dbo.CreateState");
         db.AddInputParameter("@CountryId", DbType.Int32, state.CountryId);
         db.AddInputParameter("@Country", DbType.String, state.Country);
         db.AddInputParameter("@Name", DbType.String, state.Name);
         db.AddInputParameter("@FullName", DbType.String, state.FullName);
         db.AddInputParameter("@Latitude", DbType.Double, state.Latitude);
         db.AddInputParameter("@Longitude", DbType.Double, state.Longitude);
         db.AddOutputParameter("@StateId", DbType.Int32);
         try
         {
             db.ExecuteNonQuery();
             state.StateId = db.GetParameterValue<int>("@StateId");
         }
         catch (Exception ex)
         {
             Logger.Error("Error while creating state.", ex);
             throw;
         }
     }
     return state;
 }
 public bool TryGetState(string state, string country, out State match)
 {
     using (var db = new DataAccess())
     {
         db.CreateStoredProcCommand("dbo.TryGetState");
         db.AddInputParameter("@State", DbType.String, state);
         db.AddInputParameter("@Country", DbType.String, country);
         db.AddReturnParameter();
         try
         {
             db.ReadInto(match = new State());
             return Convert.ToBoolean(db.GetReturnValue());
         }
         catch (Exception ex)
         {
             Logger.Error("Error while getting state.", ex);
         }
     }
     match = default(State);
     return false;
 }