예제 #1
0
        // GET: /Saft/
        public HttpResponseMessage Get()
        {
            string res      = MongoConnection.GetCollection("Header");
            var    response = this.Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(res, Encoding.UTF8, "application/json");

            return(response);
        }
예제 #2
0
        //-----
        public HttpResponseMessage Get(string id)
        {
            HttpResponseMessage response = null;
            string body = MongoConnection.GetCollection(id);

            response         = this.Request.CreateResponse(HttpStatusCode.OK);
            response.Content = new StringContent(body, Encoding.UTF8, "application/json");

            return(response);
        }
예제 #3
0
        public Product AddProduct(Product product)
        {
            var productDto = new ProductDto()
            {
                Id   = product.Id,
                Name = product.Name
            };

            var collection = MongoConnection.GetCollection <ProductDto>("Products");

            collection.Save(productDto);
            return(product);
        }
예제 #4
0
 public async Task AddAsync(Guid userId, string refreshToken)
 {
     var grantModel = new GrantModel()
     {
         Id           = Guid.NewGuid(),
         OwnerId      = userId,
         RefreshToken = refreshToken,
         IsValid      = true
     };
     var collection = _mongoConnection.GetCollection <GrantModel>("grantmodel");
     await collection.InsertOneAsync(grantModel);
 }
예제 #5
0
        public List <Product> GetAllProducts()
        {
            var collection     = MongoConnection.GetCollection <ProductDto>("Products");
            var storedProducts = collection.AsQueryable().ToList();

            List <Product> products = new List <Product>();

            foreach (var storedProduct in storedProducts)
            {
                products.Add(new Product()
                {
                    Id         = storedProduct.Id,
                    Name       = storedProduct.Name,
                    HashedName = HashName(storedProduct.Name)
                });
            }

            return(products);
        }
예제 #6
0
 public UserRepository(MongoConnection connection)
 {
     _userCollection    = connection.GetCollection <UserDto>();
     _companyCollection = connection.GetCollection <CompanyDto>();
 }
예제 #7
0
 public ReportRepository(MongoConnection connection)
 {
     _collection = connection.GetCollection <ReportDto>();
 }