예제 #1
0
        public void AddPricingQueryTest()
        {
            // We use a static id, so we always can drop the the user after the test
            Guid userid = new Guid("f265ab67-8006-4266-b6fd-c6a409321b31");

            // We use a static id, so we always can drop the the query after the test
            Guid queryid = new Guid("329BF626-9F06-483B-AD0F-F70E27BE30F7");

            // We use a static id, so we always can drop the the query after the test
            Guid productid = new Guid("758c0953-e576-4a8d-9223-b85ffd24c8ac");


            //Add User
            User user = new User()
            {
                Id = userid, FirstName = "Jayakaran", LastName = "Theiven", AddressLine1 = "buntspechtweg 8a", City = "Bonn", PostCode = "53123", Country = "Germany", Email = "*****@*****.**", Phone = "00491739476008"
            };

            userRepository.Add(user);

            //Add Product
            Product product = new Product()
            {
                Id = productid, Name = "Test Product"
            };

            productRepository.Add(product);

            //insert pricing query
            PricingQuery query = new PricingQuery()
            {
                Id = queryid, ProductId = productid, UserId = userid, EnquiryDate = DateTime.Today, IsReplied = false
            };

            pricingQueryRepository.Add(query);

            // return pricing query data and test

            var result = pricingQueryRepository.Find(queryid);

            Assert.That(result.Id, Is.EqualTo(queryid));
            Assert.That(result.UserId, Is.EqualTo(userid));
            Assert.That(result.ProductId, Is.EqualTo(productid));

            //Clean up after testing
            PricingQueryCleanUp(queryid);
            UserCleanUp(userid);
            ProductCleanUp(productid);
        }
        public void Add(PricingQuery entity)
        {
            using (IDbConnection cn = connection)
            {
                var parameters = new
                {
                    UserId        = entity.UserId,
                    ProductId     = entity.ProductId,
                    EnquiryDate   = entity.EnquiryDate,
                    RespondedDate = entity.RespondedDate,
                    IsReplied     = entity.IsReplied,
                    Id            = entity.Id,
                };

                cn.Open();
                entity.Id = cn.Query <Guid>(
                    "INSERT INTO PricingQuery (UserId, ProductId, EnquiryDate, RespondedDate, IsReplied, Id) VALUES(@UserId, @ProductId, @EnquiryDate, @RespondedDate, @IsReplied,  @Id)",
                    parameters).FirstOrDefault();
            }
        }