public ActionResult Update([FromBody] ResultInterestPointViewModel c)
        {
            var currentResult = _bo.Read(c.Id);

            if (!currentResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            var current = currentResult.Result;

            if (current == null)
            {
                return(NotFound());
            }
            if (current.ResultId == c.ResultId && current.InterestPointId == c.InterestPointId)
            {
                return(new ObjectResult(HttpStatusCode.NotModified));
            }

            if (current.ResultId != c.ResultId)
            {
                current.ResultId = c.ResultId;
            }
            if (current.InterestPointId != c.InterestPointId)
            {
                current.InterestPointId = c.InterestPointId;
            }
            var updateResultInterestPoint = _bo.Update(current);

            if (!updateResultInterestPoint.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
Пример #2
0
        public void TestUpdateResultInterestPoint()
        {
            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.Update(item);

            resList = ripbo.List();

            Assert.IsTrue(resList.Success && resUpdate.Success &&
                          resList.Result.First().ResultId == item.ResultId && resList.Result.First().InterestPointId == item.InterestPointId);
        }