Ejemplo n.º 1
0
        public Warehouse Save(string name)
        {
            var warstoryDocuments = _server.GetDatabase("warstory-documents");
            Warehouse warehouseDocument = null;
            using (_server.RequestStart(warstoryDocuments))
            {

                var warehouseDocuments = warstoryDocuments.GetCollection<Warehouse>("warehouse-documents");
                var query = Query.EQ("_id", name);

                warehouseDocument = warehouseDocuments.FindAs<Warehouse>(query).SingleOrDefault();
                if (warehouseDocument != null)
                {
                    warehouseDocument.Action();
                    warehouseDocuments.Save<Warehouse>(warehouseDocument);
                }
                else
                {
                    warehouseDocument = new Warehouse { Name = "Chavp" };
                    warehouseDocuments.Save<Warehouse>(warehouseDocument);
                }
            }

            return warehouseDocument;
        }
Ejemplo n.º 2
0
        public Warehouse Save(Warehouse warehouse)
        {
            var warstoryDocuments = _server.GetDatabase("warstory-documents");
            using (_server.RequestStart(warstoryDocuments))
            {

                var warehouseDocuments = warstoryDocuments.GetCollection<Warehouse>("warehouse-documents");
                warehouseDocuments.Save<Warehouse>(warehouse);
            }

            return warehouse;
        }