Beispiel #1
0
 public static ResultInterestPointViewModel Parse(ResultInterestPoint resultInterestPoint)
 {
     return(new ResultInterestPointViewModel()
     {
         Id = resultInterestPoint.Id,
         ResultId = resultInterestPoint.ResultId,
         InterestPointId = resultInterestPoint.InterestPointId
     });
 }
        public ActionResult Create([FromBody] ResultInterestPointViewModel vm)
        {
            var c = new ResultInterestPoint(vm.ResultId, vm.InterestPointId);

            var res  = _bo.Create(c);
            var code = res.Success ? HttpStatusCode.OK : HttpStatusCode.InternalServerError;

            return(new ObjectResult(code));
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
 public OperationResult Delete(ResultInterestPoint resultInterestPoint)
 {
     try
     {
         _dao.Delete(resultInterestPoint);
         return(new OperationResult()
         {
             Success = true
         });
     }
     catch (Exception e)
     {
         return(new OperationResult()
         {
             Success = true, Exception = e
         });
     }
 }
        public async Task <OperationResult> DeleteAsync(ResultInterestPoint resultInterestPoint)
        {
            try
            {
                await _dao.DeleteAsync(resultInterestPoint);

                return(new OperationResult()
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult()
                {
                    Success = true, Exception = e
                });
            }
        }
Beispiel #7
0
        public static void  Seed()
        {
            using var _ctx = new BoraNowContext();
            _ctx.Database.EnsureDeleted();
            _ctx.Database.EnsureCreated();
            var categoryOne     = new CategoryInterestPoint("VeganFood");
            var categoryTwo     = new CategoryInterestPoint("SeaFood");
            var categoryThree   = new CategoryInterestPoint("AsianFood");
            var quiz            = new Quiz("BoraNow quiz");
            var quizQuestion    = new QuizQuestion("What type of food are you looking for?", quiz.Id);
            var quizAnswerOne   = new QuizAnswer("Vegan", quizQuestion.Id);
            var quizAnswerTwo   = new QuizAnswer("Sea food", quizQuestion.Id);
            var quizAnswerThree = new QuizAnswer("Asian style", quizQuestion.Id);


            var countryOne = new Country("Angola");
            var countryTwo = new Country("Portugal");
            var profileOne = new Profile("blogueira vegana que adora viajar e conhecer novos locais", "mefamousstar.jpg");
            var profileTwo = new Profile("Business Man with a chain of restauarants across Lisbon", "merichstar.jpg");
            var company    = new Company("PearTree Company", "Marco Pereria", "919200000", "23453554", profileTwo.Id);
            var visitor    = new Visitor("Bruna", "Costa", DateTime.Now.AddYears(-24), "Female", profileOne.Id, countryOne.Id);


            var interestPoint         = new InterestPoint("PearTree Abc", "very chill place that offers lots off tradicional food", "abc street", "uhuhuu.jpg", "3 am", "5 pm", "fridays", true, true, company.Id);
            var interestPointCategory = new InterestPointCategoryInterestPoint(interestPoint.Id, categoryOne.Id);
            var result = new Result("questionário nº 1", DateTime.Now, quiz.Id, visitor.Id);
            var resultInterestPoint = new ResultInterestPoint(result.Id, interestPoint.Id);

            var newsletter = new Newsletter("New place in town that has many vegan options", "Brand New");
            var interestPointNewsletter = new InterestPointNewsletter(interestPoint.Id, newsletter.Id);

            var meteorology = new Meteorology(19, 27, 0, 1, 0, DateTime.Now.AddDays(1));
            var feedback    = new Feedback("very nice place, cousy vibes, really good food", 5, DateTime.Now.AddDays(-1), interestPoint.Id, visitor.Id);



            _ctx.Country.AddRange(countryOne);
            _ctx.Country.AddRange(countryTwo);
            _ctx.Profile.AddRange(profileOne);
            _ctx.Profile.AddRange(profileTwo);
            _ctx.Company.AddRange(company);
            _ctx.Visitor.AddRange(visitor);

            _ctx.Category.AddRange(categoryOne);
            _ctx.Category.AddRange(categoryTwo);
            _ctx.Category.AddRange(categoryThree);
            _ctx.Quiz.AddRange(quiz);
            _ctx.QuizQuestion.AddRange(quizQuestion);
            _ctx.QuizAnswer.AddRange(quizAnswerOne);
            _ctx.QuizAnswer.AddRange(quizAnswerTwo);
            _ctx.QuizAnswer.AddRange(quizAnswerThree);
            _ctx.InterestPoint.AddRange(interestPoint);
            _ctx.InterestPointCategory.AddRange(interestPointCategory);
            _ctx.Result.AddRange(result);
            _ctx.ResultInterestPoint.AddRange(resultInterestPoint);

            _ctx.Newsletter.AddRange(newsletter);
            _ctx.InterestPointNewsletter.AddRange(interestPointNewsletter);

            _ctx.Feedback.AddRange(feedback);
            _ctx.Meteorology.AddRange(meteorology);

            _ctx.SaveChanges();
        }
Beispiel #8
0
 public async Task DeleteAsync(ResultInterestPoint resultInterestPoint)
 {
     resultInterestPoint.IsDeleted = true;
     await UpdateAsync(resultInterestPoint);
 }
Beispiel #9
0
 public void Delete(ResultInterestPoint resultInterestPoint)
 {
     resultInterestPoint.IsDeleted = true;
     Update(resultInterestPoint);
 }
Beispiel #10
0
 public async Task UpdateAsync(ResultInterestPoint resultInterestPoint)
 {
     _context.Entry(resultInterestPoint).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Beispiel #11
0
 public void Update(ResultInterestPoint resultInterestPoint)
 {
     _context.Entry(resultInterestPoint).State = EntityState.Modified;
     _context.SaveChanges();
 }
Beispiel #12
0
        public async Task CreateAsync(ResultInterestPoint resultInterestPoint)
        {
            await _context.ResultInterestPoint.AddAsync(resultInterestPoint);

            await _context.SaveChangesAsync();
        }
Beispiel #13
0
 public void Create(ResultInterestPoint resultInterestPoint)
 {
     _context.ResultInterestPoint.Add(resultInterestPoint);
     _context.SaveChanges();
 }