Пример #1
0
        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 getClientOperation = await _clientBO.ReadAsync(getOperation.Result.ClientId);

            if (!getClientOperation.Success)
            {
                return(OperationErrorBackToIndex(getClientOperation.Exception));
            }

            if (getClientOperation.Result == null)
            {
                return(RecordNotFound());
            }

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

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Details", Controller = "Comments", Icon = "fa-info-circle", Text = "Details"
            });

            ViewData["Title"]       = "Comment details";
            ViewData["BreadCrumbs"] = crumbs;
            ViewData["Client"]      = ClientVM.Parse(getClientOperation.Result);
            return(View(vm));
        }
Пример #2
0
        public void TestCreateAndListCommentAsync()
        {
            ApplicationSeeder.Seed();

            var bo        = new CommentBO();
            var foreignBO = new ClientBO();

            var comment = new Comment("Tou só a testar", foreignBO.ListUndeleted().Result.First().Id);

            var resCreate = bo.CreateAsync(comment).Result;
            var resGet    = bo.ReadAsync(comment.Id).Result;

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