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

            ViewData["Title"] = "Company";

            var crumbs = GetCrumbs();

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

            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
        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 getROperation = await _rbo.ReadAsync(getOperation.Result.RegionId);
            if (!getROperation.Success) return OperationErrorBackToIndex(getROperation.Exception);
            if (getROperation.Result == null) return RecordNotFound();

            var getCOperation = await _cbo.ReadAsync(getOperation.Result.CompanyId);
            if (!getCOperation.Success) return OperationErrorBackToIndex(getCOperation.Exception);
            if (getCOperation.Result == null) return RecordNotFound();

            var vm = EstablishmentViewModel.Parse(getOperation.Result);
            ViewData["Title"] = "Establishment";

            var crumbs = GetCrumbs();
            crumbs.Add(new BreadCrumb() { Action = "Details", Controller = "Establishments", Icon = "fa-search", Text = "Detail" });

            ViewData["Region"] = RegionViewModel.Parse(getROperation.Result);
            ViewData["Company"] = CompanyViewModel.Parse(getCOperation.Result);
            ViewData["BreadCrumbs"] = crumbs;
            return View(vm);
        }
Example #3
0
        public void TestCreateAndReadCompanyAsync()
        {
            ContextSeeder.Seed();
            var bo        = new CompanyBusinessObject();
            var reg       = new Company("Sonae", 1823445);
            var resCreate = bo.CreateAsync(reg).Result;
            var resGet    = bo.ReadAsync(reg.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Example #4
0
        public void TestCreateCompanyAsync()
        {
            BoraNowSeeder.Seed();
            var cbo = new CompanyBusinessObject();
            var pbo = new ProfileBusinessObject();

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

            pbo.Create(profile);

            var company = new Company("B", "C", "123", "234", profile.Id);


            var resCreate = cbo.CreateAsync(company).Result;
            var resGet    = cbo.ReadAsync(company.Id).Result;

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

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