public JsonResult Index(Translation translation) { using (var session = documentStore.OpenSession()) { session.Store(translation); session.SaveChanges(); } return Json(translation, JsonRequestBehavior.AllowGet); }
public static void Init() { using (var session = documentStore.OpenSession()) { var dataExist = false; try { dataExist = session.Query<Translation>().Any(); } catch{} if (!dataExist) { var random = new Random(); for (int i = 0; i < 100; i++ ) { var key = new string(new []{Convert.ToChar(random.Next(65, 90)), Convert.ToChar(random.Next(97,122)), Convert.ToChar(random.Next(97,122)), Convert.ToChar(random.Next(97,122)), Convert.ToChar(random.Next(97,122))}); var value = new string(new []{Convert.ToChar(random.Next(65, 90)), Convert.ToChar(random.Next(97,122)), Convert.ToChar(random.Next(97,122)), Convert.ToChar(random.Next(97,122)), Convert.ToChar(random.Next(97,122))}); var translation = new Translation{Key = key, Value=value}; session.Store(translation); } session.SaveChanges(); } } }