示例#1
0
        public void TestDeleteVisitor()
        {
            BoraNowSeeder.Seed();
            var vbo       = new VisitorBusinessObject();
            var resList   = vbo.List();
            var resDelete = vbo.Delete(resList.Result.First().Id);

            resList = vbo.List();

            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.First().IsDeleted);
        }
示例#2
0
        public void TestListVisitor()
        {
            BoraNowSeeder.Seed();
            var vbo     = new VisitorBusinessObject();
            var resList = vbo.List();

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
示例#3
0
        public void TestUpdateVisitor()
        {
            BoraNowSeeder.Seed();
            var vbo     = new VisitorBusinessObject();
            var resList = vbo.List();
            var item    = resList.Result.FirstOrDefault();


            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("R", "f", DateTime.Now.AddYears(-24), "F", profile.Id, country.Id);

            item.FirstName = visitor.FirstName;
            item.LastName  = visitor.LastName;
            item.BirthDate = visitor.BirthDate;
            item.Gender    = visitor.Gender;
            item.ProfileId = visitor.ProfileId;
            item.CountryId = visitor.CountryId;

            var resUpdate = vbo.Update(item);

            resList = vbo.List();

            Assert.IsTrue(resUpdate.Success && resList.Success &&
                          resList.Result.First().FirstName == visitor.FirstName && resList.Result.First().LastName == visitor.LastName &&
                          resList.Result.First().BirthDate == visitor.BirthDate && resList.Result.First().Gender == visitor.Gender &&
                          resList.Result.First().ProfileId == visitor.ProfileId &&
                          resList.Result.First().CountryId == visitor.CountryId);
        }
示例#4
0
        public ActionResult <List <VisitorViewModel> > List()
        {
            var res = _bo.List();

            if (!res.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var list = new List <VisitorViewModel>();

            foreach (var item in res.Result)
            {
                list.Add(VisitorViewModel.Parse(item));
            }
            return(list);
        }