Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            var things = db.Things.Where(m => m.ClientID == id).ToList();

            if (things.Count < 1)
            {
                db.DeleteClient(id);
            }
            else
            {
                TempData["ErrorMessage"] = "Error! There are things attached to this client. Please remove them in order to delete this client.";
                return(RedirectToAction("Delete", new { id = id }));
            }
            return(RedirectToAction("Index"));
        }