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 vm = NewsletterViewModel.Parse(getOperation.Result);

            ViewData["Title"] = "Newsletter";

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "New", Controller = "Newsletters", Icon = "fa-search", Text = "Detail"
            });

            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
示例#2
0
        public void TestCreateNewsletterAsync()
        {
            BoraNowSeeder.Seed();
            var nbo = new NewsletterBusinessObject();

            var news = new Newsletter("New in town, this doughnut place is nuts", "New in town");

            var resCreate = nbo.CreateAsync(news).Result;
            var restGet   = nbo.ReadAsync(news.Id).Result;

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