예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Company company = _companiesRepository.FindCompanyById(id);

            if (company != null)
            {
                ViewBag.SelectedNav = "Dashboard";
                if (company.JobListings.Count() < 1)
                {
                    _companiesRepository.DeleteCompany(company);
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    TempData["ErrorMessage"] = $"Company '{company.Name}' has active job listings and cannot be deleted.";
                    return(RedirectToAction(nameof(Index)));
                }
            }
            ViewBag.SelectedNav = "Dashboard";
            return(RedirectToAction(nameof(Index)));
        }