Created
February 21, 2012 08:42
-
-
Save lazypower/1875193 to your computer and use it in GitHub Desktop.
CouchDB Wrapper Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AffiliateID": "1234", | |
"CampaignID": "test", | |
"AreaOfInterest": "Art and Design", | |
"ProgramCategory": "Photography", | |
"Schools": [ | |
"AIO", | |
"IADT" | |
], | |
"EducationComplete": [ | |
{ | |
"Key": "IADT", | |
"Value": { | |
"$type": "C5.HashSet`1[[System.String, mscorlib]], C5", | |
"$values": [ | |
"BDG", | |
"HS", | |
"ADG", | |
"GED" | |
] | |
} | |
}, | |
{ | |
"Key": "AIO", | |
"Value": { | |
"$type": "C5.HashSet`1[[System.String, mscorlib]], C5", | |
"$values": [ | |
"GED", | |
"ADG", | |
"BDG", | |
"HS" | |
] | |
} | |
} | |
], | |
"StateBan": [ | |
{ | |
"Key": "AIO", | |
"Value": { | |
"$type": "C5.HashSet`1[[System.String, mscorlib]], C5", | |
"$values": [ | |
"TN" | |
] | |
} | |
} | |
], | |
"ExitURL": null | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Raven.Client; | |
using Raven.Client.Document; | |
using UBoundTools.Rules.Models; | |
namespace Admin.Controllers | |
{ | |
public class RuleController : Controller | |
{ | |
public String Index() | |
{ | |
var store = new DocumentStore { Url = "http://localhost:8080" }; | |
store.Initialize(); | |
using (IDocumentSession session = store.OpenSession()) | |
{ | |
Rule x = new Rule | |
{ | |
AffiliateID = "1234", | |
AreaOfInterest = "Art and Design", | |
ProgramCategory = "Photography", | |
CampaignID = "test" | |
}; | |
x.Schools = new List<string>(); | |
x.Schools.Add("AIO"); | |
x.Schools.Add("IADT"); | |
x.EducationComplete = new MultiHashDictionary<string, string>(); | |
x.EducationComplete.Add("AIO", "GED"); | |
x.EducationComplete.Add("AIO", "HS"); | |
x.EducationComplete.Add("AIO", "ADG"); | |
x.EducationComplete.Add("AIO", "BDG"); | |
x.EducationComplete.Add("IADT", "GED"); | |
x.EducationComplete.Add("IADT", "HS"); | |
x.EducationComplete.Add("IADT", "ADG"); | |
x.EducationComplete.Add("IADT", "BDG"); | |
x.StateBan = new MultiHashDictionary<string, string>(); | |
x.StateBan.Add("AIO", "TN"); | |
session.Store(x); | |
session.SaveChanges(); | |
return "fin!"; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment