public FundingTypeObject SaveFundingType(FundingTypeObject fundingType) { if (fundingType.FundingTypeId > 0) // Update { string sql = @" UPDATE lu_FundingType SET FundingType = @FundingType, Description = @Description, Active = @Active WHERE FundingTypeId = @FundingTypeId"; Config.Conn.Execute(sql, fundingType); } else { string sql = @" INSERT INTO lu_FundingType ( FundingType, Description, Active ) VALUES ( @FundingType, @Description, @Active ) SELECT CAST(SCOPE_IDENTITY() AS INT)"; fundingType.FundingTypeId = Config.Conn.Query <int>(sql, fundingType).Single(); } return(fundingType); }
public bool DeleteFundingType(FundingTypeObject fundingType) { try { Config.Conn.Execute("DELETE FROM lu_FundingType WHERE FundingTypeId = @FundingTypeId", fundingType); } catch { return(false); } return(true); }
public static List <FundingTypeObject> GetFundingTypes(bool enabledOnly = false, int?requiredId = null) { var cache = HttpContext.Current.Cache; List <FundingTypeObject> data = (List <FundingTypeObject>)cache[FundingTypeKey]; if (data == null) { data = FundingTypeObject.GetFundingTypes(); cache.Insert(FundingTypeKey, data, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration); } return(data.Where(n => (!enabledOnly || n.Active || (requiredId.HasValue && n.FundingTypeId == requiredId.Value))).ToList()); }