Example #1
0
        public ActionResult Update([FromBody] InterestPointNewsletterViewModel vm)
        {
            var currentResult = _bo.Read(vm.Id);

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

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

            if (current.InterestPointId != vm.InterestPointId)
            {
                current.InterestPointId = vm.InterestPointId;
            }
            if (current.NewsLetterId != vm.NewsLetterId)
            {
                current.NewsLetterId = vm.NewsLetterId;
            }


            var updateResult = _bo.Update(current);

            if (!updateResult.Success)
            {
                return(new ObjectResult(HttpStatusCode.InternalServerError));
            }
            return(Ok());
        }
Example #2
0
        public void TestUpdateInterestPointNewsletter()
        {
            BoraNowSeeder.Seed();
            var ipnbo   = new InterestPointNewsletterBusinessObject();
            var resList = ipnbo.List();
            var item    = resList.Result.FirstOrDefault();

            var nbo  = new NewsletterBusinessObject();
            var cbo  = new CompanyBusinessObject();
            var ipbo = new InterestPointBusinessObject();
            var pbo  = new ProfileBusinessObject();

            var profile = new Profile("II", "AA");

            pbo.Create(profile);

            var news          = new Newsletter("New in town, this doughnut place is nuts", "New in town");
            var company       = new Company("a", "b", "c", "123333", profile.Id);
            var interestPoint = new InterestPoint("a", "b", "c", "d", "e", "f", "g", true, true, company.Id);

            nbo.Create(news);
            cbo.Create(company);
            ipbo.Create(interestPoint);

            var newInterestPointNews = new InterestPointNewsletter(interestPoint.Id, news.Id);

            item.InterestPointId = newInterestPointNews.InterestPointId;
            item.NewsLetterId    = newInterestPointNews.NewsLetterId;

            var resUpdate = ipnbo.Update(item);

            resList = ipnbo.List();

            Assert.IsTrue(resUpdate.Success && resList.Success &&
                          resList.Result.First().InterestPointId == newInterestPointNews.InterestPointId && resList.Result.First().NewsLetterId == newInterestPointNews.NewsLetterId);
        }