public async Task <IActionResult> New()
        {
            var listClientOperation = await _clientBO.ListUndeletedAsync();

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

            var clientList = new List <SelectListItem>();

            foreach (var item in listClientOperation.Result)
            {
                var clientName = await _profileBO.ReadAsync(item.ProfileId);

                clientList.Add(new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = (clientName.Result.FullName + " -- " + clientName.Result.Country)
                });
            }

            ViewBag.Clients = clientList;

            var crumbs = GetCrumbs();

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

            ViewData["Title"]       = "New comment";
            ViewData["BreadCrumbs"] = crumbs;
            return(View());
        }
        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 = ProfileVM.Parse(getOperation.Result);

            var crumbs = GetCrumbs();

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

            ViewData["Title"]       = "Profile details";
            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
        public void TestCreateAndListProfileAsync()
        {
            ApplicationSeeder.Seed();

            var bo      = new ProfileBO();
            var profile = new Profile("John Doe", "Portugal", DateTime.Now);

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

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
        private async Task <ProfileVM> GetProfileViewModel(Guid id)
        {
            var getOperation = await _profileBO.ReadAsync(id);

            return(ProfileVM.Parse(getOperation.Result));
        }