Esempio n. 1
0
        public void TestCreateResultAsync()
        {
            var rbo = new ResultBusinessObject();
            var qbo = new QuizBusinessObject();
            var vbo = new VisitorBusinessObject();

            var quiz = new Quiz("Quiz 1");

            qbo.Create(quiz);

            var countrybo = new CountryBusinessObject();
            var pbo       = new ProfileBusinessObject();
            var companybo = new CompanyBusinessObject();

            var country = new Country("Holanda");
            var profile = new Profile("a", "b");
            var company = new Company("a", "b", "c", "d", profile.Id);

            countrybo.Create(country);
            pbo.Create(profile);
            companybo.Create(company);

            var visitor = new Visitor("B", "N", DateTime.Now, "Male", profile.Id, country.Id);

            vbo.Create(visitor);

            var result = new Result("Q1 Result", DateTime.UtcNow, quiz.Id, visitor.Id);

            var resCreate = rbo.CreateAsync(result).Result;
            var resGet    = rbo.ReadAsync(result.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Esempio n. 2
0
        public void TestUpdateResultInterestPointAsync()
        {
            BoraNowSeeder.Seed();
            var ripbo   = new ResultInterestPointBusinessObject();
            var resList = ripbo.List();
            var item    = resList.Result.FirstOrDefault();

            var rbo  = new ResultBusinessObject();
            var ipbo = new InterestPointBusinessObject();

            var vbo = new VisitorBusinessObject();

            var qbo  = new QuizBusinessObject();
            var quiz = new Quiz("Quiz 1");

            qbo.Create(quiz);

            var countrybo = new CountryBusinessObject();
            var pbo       = new ProfileBusinessObject();
            var companybo = new CompanyBusinessObject();

            var country = new Country("Holanda");
            var profile = new Profile("a", "b");
            var company = new Company("a", "b", "c", "d", profile.Id);

            countrybo.Create(country);
            pbo.Create(profile);
            companybo.Create(company);


            var visitor = new Visitor("A", "E", DateTime.Now, "M", profile.Id, country.Id);

            vbo.Create(visitor);

            var result = new Result("Quiz 2", DateTime.UtcNow, quiz.Id, visitor.Id);

            var interestPoint = new InterestPoint("Bar do Rui", "Pesticos&Cocktails", "-", "C://images", "14h", "00h", "D", true, true, company.Id);

            rbo.Create(result);
            ipbo.Create(interestPoint);

            var resultInterestPoint = new ResultInterestPoint(result.Id, interestPoint.Id);

            item.ResultId        = resultInterestPoint.ResultId;
            item.InterestPointId = resultInterestPoint.InterestPointId;
            var resUpdate = ripbo.UpdateAsync(item).Result;

            resList = ripbo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().ResultId == item.ResultId && resList.Result.First().InterestPointId == item.InterestPointId);
        }
Esempio n. 3
0
        public ActionResult Create([FromBody] VisitorViewModel vm)
        {
            var visitor = new Visitor(vm.FirstName, vm.LastName, vm.BirthDate, vm.Gender, vm.ProfileId, vm.CountryId);

            var res = _bo.Create(visitor);

            if (!res.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            else
            {
                return(new ObjectResult(HttpStatusCode.OK));
            }
        }
Esempio n. 4
0
        public void TestUpdateResultAsync()
        {
            BoraNowSeeder.Seed();
            var rbo     = new ResultBusinessObject();
            var resList = rbo.List();
            var item    = resList.Result.FirstOrDefault();

            var qbo  = new QuizBusinessObject();
            var quiz = new Quiz("Quiz 2");

            qbo.Create(quiz);

            var countrybo = new CountryBusinessObject();
            var pbo       = new ProfileBusinessObject();
            var companybo = new CompanyBusinessObject();

            var country = new Country("Holanda");
            var profile = new Profile("a", "b");
            var company = new Company("a", "b", "c", "d", profile.Id);

            countrybo.Create(country);
            pbo.Create(profile);
            companybo.Create(company);


            var vbo     = new VisitorBusinessObject();
            var visitor = new Visitor("B", "N", DateTime.Now, "Male", profile.Id, country.Id);

            vbo.Create(visitor);

            var result = new Result("Q1 Result", DateTime.UtcNow, quiz.Id, visitor.Id);

            item.Title     = result.Title;
            item.Date      = result.Date;
            item.QuizId    = result.QuizId;
            item.VisitorId = result.VisitorId;
            var resUpdate = rbo.Update(item);

            resList = rbo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().Title == item.Title &&
                          resList.Result.First().Date == item.Date &&
                          resList.Result.First().QuizId == item.QuizId &&
                          resList.Result.First().VisitorId == item.VisitorId);
        }
Esempio n. 5
0
        public void TestCreateResultInterestPointAsync()
        {
            var ripbo = new ResultInterestPointBusinessObject();
            var rbo   = new ResultBusinessObject();
            var ipbo  = new InterestPointBusinessObject();

            var vbo = new VisitorBusinessObject();

            var qbo  = new QuizBusinessObject();
            var quiz = new Quiz("Quiz 1");

            qbo.Create(quiz);

            var countrybo = new CountryBusinessObject();
            var pbo       = new ProfileBusinessObject();
            var companybo = new CompanyBusinessObject();

            var country = new Country("Holanda");
            var profile = new Profile("a", "b");
            var company = new Company("a", "b", "c", "d", profile.Id);

            countrybo.Create(country);
            pbo.Create(profile);
            companybo.Create(company);


            var visitor = new Visitor("A", "C", DateTime.Now, "M", profile.Id, country.Id);

            vbo.Create(visitor);

            var result = new Result("Quiz 1", DateTime.UtcNow, quiz.Id, visitor.Id);

            var interestPoint = new InterestPoint("Bar do Rui", "Pesticos&Cocktails", "Rua dos Anjos", "C://images", "14h", "00h", "Sabados", true, true, company.Id);

            rbo.Create(result);
            ipbo.Create(interestPoint);

            var _resultInterestPoint = new ResultInterestPoint(result.Id, interestPoint.Id);


            var resCreate = ripbo.CreateAsync(_resultInterestPoint).Result;
            var resGet    = ripbo.ReadAsync(_resultInterestPoint.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Esempio n. 6
0
        public void TestCreateVisitor()
        {
            BoraNowSeeder.Seed();
            var vbo = new VisitorBusinessObject();

            var countrybo = new CountryBusinessObject();
            var pbo       = new ProfileBusinessObject();
            var companybo = new CompanyBusinessObject();

            var country = new Country("Holanda");
            var profile = new Profile("a", "b");
            var company = new Company("a", "b", "c", "d", profile.Id);

            countrybo.Create(country);
            pbo.Create(profile);
            companybo.Create(company);

            var visitor = new Visitor("m", "f", DateTime.Now.AddYears(-24), "m", profile.Id, country.Id);

            var resCreate = vbo.Create(visitor);
            var restGet   = vbo.Read(visitor.Id);

            Assert.IsTrue(resCreate.Success && restGet.Success && restGet.Result != null);
        }