public async Task<ActionResult> List()
        {
            var model = new CompanyModel();
            var response = await _companiesService.GetCompanies();

            return View(model.Adapt(response.Companies));
        }
        public async Task<ActionResult> Create(CompanyModel company)
        {
            if (ModelState.IsValid)
            {
                await _companiesService.CreateCompany(new CreateCompanyRequest
                {
                    Name = company.Name,
                    CompanyCode = company.CompanyCode
                });
                return RedirectToAction("List");
            }

            return View(company);
        }
        public async Task<ActionResult> Edit(long? id)
        {
            if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            var model = new CompanyModel();
            var getCompanyResponse = await _companiesService.GetCompanyById(new GetCompanyRequest
            {
                CompanyId = (long)id,
                CorrelationId = Guid.NewGuid().ToString(),
                Requestor = ClaimsPrincipal.Current.Identity.Name
            });

            if (getCompanyResponse.Company == null) return HttpNotFound();

            return View(model.Adapt(getCompanyResponse.Company));
        }
 public async Task<ActionResult> DeleteConfirmed(long id)
 {
     var model = new CompanyModel();
     var getCompanyResponse = await _companiesService.GetCompanyById(new GetCompanyRequest
     {
         CompanyId = id,
         CorrelationId = Guid.NewGuid().ToString(),
         Requestor = ClaimsPrincipal.Current.Identity.Name
     });
     if (getCompanyResponse.Company.Users.Any())
     {
         model = model.Adapt(getCompanyResponse.Company);
         model.Errors = true;
         model.ErrorMessage = "There are users associated with this company.";
         return View(model);
     }
     await _companiesService.DeleteCompany(new DeleteCompanyRequest
     {
         CompanyId = id,
         CorrelationId = Guid.NewGuid().ToString(),
         Requestor = ClaimsPrincipal.Current.Identity.Name
     });
     return RedirectToAction("List");
 }