public SponsorOrgObject SaveSponsorOrg(SponsorOrgObject sponsorOrg) { if (sponsorOrg.SponsorOrgId > 0) // Update { string sql = @" UPDATE lu_SponsorOrg SET Name = @Name, Code = @Code, Active = @Active WHERE SponsorOrgId = @SponsorOrgId"; Config.Conn.Execute(sql, sponsorOrg); } else { string sql = @" INSERT INTO lu_SponsorOrg ( Name, Code, Active ) VALUES ( @Name, @Code, @Active ) SELECT CAST(SCOPE_IDENTITY() AS INT)"; sponsorOrg.SponsorOrgId = Config.Conn.Query <int>(sql, sponsorOrg).Single(); } return(sponsorOrg); }
public bool DeleteSponsorOrg(SponsorOrgObject sponsorOrg) { try { Config.Conn.Execute("DELETE FROM lu_SponsorOrg WHERE SponsorOrgId = @SponsorOrgId", sponsorOrg); } catch { return(false); } return(true); }
public static List <SponsorOrgObject> GetSponsoringOrgs(bool enabledOnly = false, int?requiredId = null) { var cache = HttpContext.Current.Cache; List <SponsorOrgObject> data = (List <SponsorOrgObject>)cache[SponsorOrgKey]; if (data == null) { data = SponsorOrgObject.GetSponsorOrgs(); cache.Insert(SponsorOrgKey, data, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration); } return(data.Where(n => (!enabledOnly || n.Active || (requiredId.HasValue && n.SponsorOrgId == requiredId.Value))).ToList()); }