public virtual LocaleSetting UpdateLocaleSetting(LocaleSetting entity) { if (entity.IsTransient()) { return(entity); } LocaleSetting other = GetLocaleSetting(entity.LocaleSettingId); if (entity.Equals(other)) { return(entity); } string sql = @"Update LocaleSetting set [LocaleSettingGUID]=@LocaleSettingGUID , [Name]=@Name , [Description]=@Description , [DisplayOrder]=@DisplayOrder , [CreatedOn]=@CreatedOn , [DefaultCurrencyID]=@DefaultCurrencyID where LocaleSettingID=@LocaleSettingID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@LocaleSettingID", entity.LocaleSettingId) , new SqlParameter("@LocaleSettingGUID", entity.LocaleSettingGuid) , new SqlParameter("@Name", entity.Name) , new SqlParameter("@Description", entity.Description) , new SqlParameter("@DisplayOrder", entity.DisplayOrder) , new SqlParameter("@CreatedOn", entity.CreatedOn) , new SqlParameter("@DefaultCurrencyID", entity.DefaultCurrencyId) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetLocaleSetting(entity.LocaleSettingId)); }
public virtual LocaleSetting InsertLocaleSetting(LocaleSetting entity) { LocaleSetting other = new LocaleSetting(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into LocaleSetting ( [LocaleSettingGUID] ,[Name] ,[Description] ,[DisplayOrder] ,[CreatedOn] ,[DefaultCurrencyID] ) Values ( @LocaleSettingGUID , @Name , @Description , @DisplayOrder , @CreatedOn , @DefaultCurrencyID ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@LocaleSettingID", entity.LocaleSettingId) , new SqlParameter("@LocaleSettingGUID", entity.LocaleSettingGuid) , new SqlParameter("@Name", entity.Name) , new SqlParameter("@Description", entity.Description) , new SqlParameter("@DisplayOrder", entity.DisplayOrder) , new SqlParameter("@CreatedOn", entity.CreatedOn) , new SqlParameter("@DefaultCurrencyID", entity.DefaultCurrencyId) }; 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(GetLocaleSetting(Convert.ToInt32(identity))); } return(entity); }