public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }
            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getIPOperation = await _ipbo.ReadAsync(getOperation.Result.InterestPointId);

            if (!getIPOperation.Success)
            {
                return(OperationErrorBackToIndex(getIPOperation.Exception));
            }
            if (getIPOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getNOperation = await _nbo.ReadAsync(getOperation.Result.NewsLetterId);

            if (!getNOperation.Success)
            {
                return(OperationErrorBackToIndex(getNOperation.Exception));
            }
            if (getNOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = InterestPointNewsletterViewModel.Parse(getOperation.Result);

            ViewData["Title"] = "Interest Point Newsletter";

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "InterestPointNewsletters", Icon = "fa-search", Text = "Detail"
            });
            ViewData["InterestPoints"] = InterestPointViewModel.Parse(getIPOperation.Result);
            ViewData["Newsletters"]    = NewsletterViewModel.Parse(getNOperation.Result);
            ViewData["BreadCrumbs"]    = crumbs;
            return(View(vm));
        }
Exemplo n.º 2
0
        public void TestCreateInterestPointNewsletterAsync()
        {
            BoraNowSeeder.Seed();
            var ipnbo = new InterestPointNewsletterBusinessObject();

            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 interestPointNews = new InterestPointNewsletter(interestPoint.Id, news.Id);

            var resCreate = ipnbo.CreateAsync(interestPointNews).Result;
            var restGet   = ipnbo.ReadAsync(interestPointNews.Id).Result;

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