public ActionResult EditTitles(int id, AdminControllerTitleVM titleModel)
 {
     TryUpdateModel(titleModel);
     if (ModelState.IsValid)
     {
         Title title = null;
         TitleRepository titleRepository = new TitleRepository();
         if (id > 0)
         {
             title = titleRepository.GetById(id);
             title.Name = titleModel.Title;
             titleRepository.Save(title);
             return RedirectToAction("ManageTitles");
         }
         else
         {
             title = titleRepository.GetAll(filter: t => t.Name == titleModel.Title).FirstOrDefault();
             if (title == null)
             {
                 title = new Title();
                 title.Name = titleModel.Title;
                 titleRepository.Save(title);
                 return RedirectToAction("ManageTitles");
             }
             else
             {
                 throw new ArgumentException("Invalid Title");
             }
         }
     }
     return View(titleModel);
 }
 public ActionResult ManageTitles()
 {
     TitleRepository titleRepository = new TitleRepository();
     AdminControllerTitleVM titleModel = new AdminControllerTitleVM();
     titleModel.titleList = titleRepository.GetAll();
     return View(titleModel);
 }
        public ActionResult EditTitles(int id)
        {
            Title title = new Title();
            TitleRepository titleRepository = new TitleRepository();
            AdminControllerTitleVM titleModel = new AdminControllerTitleVM();

            if (id > 0)
            {
                title = titleRepository.GetById(id);
                titleModel.Title = title.Name;
                titleModel.TitleID = id;
            }

            if (id == 0)
            {
                title.Name = titleModel.Title;
            }
            return View(titleModel);
        }