public void InitDB() { using (var s = Store.OpenSession()) { if (s.Query<Merchant>().Any()) return; for (int i = 0; i < 10; i++) { var queueId = "queues/" + Guid.NewGuid().ToString(); var merchant = new Merchant { Id = "merchants/" + Guid.NewGuid(), Address = "addr " + Guid.NewGuid(), Longitude = s_random.NextDouble(), Latitude = s_random.NextDouble(), Name = Guid.NewGuid().ToString(), QueueIds = new[] {queueId} }; var queue = new Queue { Id = queueId, MerchantId = merchant.Id }; s.Store(queue); s.Store(merchant); } s.SaveChanges(); } }
public ActionResult Merchant(string name, string address, double latitude, double longitude) { using (var session = MvcApplication.Store.OpenSession()) { var queueId = "queues/" + Guid.NewGuid(); var merchant = new Merchant { Name = name, Longitude = longitude, Latitude = latitude, Address = address, QueueIds = new[] {queueId} }; session.Store(merchant); var queue = new Queue {Id = queueId, MerchantId = merchant.Id, LastPosition = 1}; session.Store(queue); session.SaveChanges(); } return View("Ok"); }