public virtual CreditCardType UpdateCreditCardType(CreditCardType entity) { if (entity.IsTransient()) { return(entity); } CreditCardType other = GetCreditCardType(entity.CardTypeId); if (entity.Equals(other)) { return(entity); } string sql = @"Update CreditCardType set [CardTypeGUID]=@CardTypeGUID , [CardType]=@CardType , [Accepted]=@Accepted , [CreatedOn]=@CreatedOn where CardTypeID=@CardTypeID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@CardTypeID", entity.CardTypeId) , new SqlParameter("@CardTypeGUID", entity.CardTypeGuid) , new SqlParameter("@CardType", entity.CardType) , new SqlParameter("@Accepted", entity.Accepted) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetCreditCardType(entity.CardTypeId)); }
public virtual CreditCardType InsertCreditCardType(CreditCardType entity) { CreditCardType other = new CreditCardType(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into CreditCardType ( [CardTypeGUID] ,[CardType] ,[Accepted] ,[CreatedOn] ) Values ( @CardTypeGUID , @CardType , @Accepted , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@CardTypeID", entity.CardTypeId) , new SqlParameter("@CardTypeGUID", entity.CardTypeGuid) , new SqlParameter("@CardType", entity.CardType) , new SqlParameter("@Accepted", entity.Accepted) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray); if (identity == DBNull.Value) { throw new DataException("Identity column was null as a result of the insert operation."); } return(GetCreditCardType(Convert.ToInt32(identity))); } return(entity); }