public ActionResult AddLibrarian(Librarian newLibrarian)
 {
     if (ModelState.IsValid)
     {
         if (newLibrarian.UserName.Contains(" "))
         {
             TempData["ErrorNoti"] = "Username can't have space character.";
             return View(newLibrarian);
         }
         else if (!StringUtil.IsAsciiCharacter(newLibrarian.UserName))
         {
             TempData["ErrorNoti"] = "Username can't have non-ascii character.";
             return View(newLibrarian);
         }
         else if ((libRepo.MemberRepo.ListWhere(target => target.UserName.ToLower() == newLibrarian.UserName.ToLower() || target.Email.ToLower() == newLibrarian.Email.ToLower()).Count == 0) &&
         (libRepo.LibrarianRepo.ListWhere(target => target.UserName.ToLower() == newLibrarian.UserName.ToLower() || target.Email.ToLower() == newLibrarian.Email.ToLower()).Count == 0))
         {
             newLibrarian.Password = Crypto.HashPassword(newLibrarian.Password);
             libRepo.LibrarianRepo.Add(newLibrarian);
             libRepo.Save();
             AuthenticateController.AddUser(newLibrarian.UserName);
             TempData["SuccessNoti"] = "Add librarian " + newLibrarian.UserName + " successfully.";
             return RedirectToAction("Index");
         }
         else
         {
             TempData["ErrorNoti"] = "This username or e-mail is already exists.";
         }
     }
     return View(newLibrarian);
 }
 public ActionResult Delete(Librarian target)
 {
     if (ModelState.IsValid)
     {
         if (libRepo.LibrarianRepo.List().Count == 1)
         {
             TempData["ErrorNoti"] = "Can't delete the only one librarian remain out of system.";
             return RedirectToAction("Index");
         }
             libRepo.LibrarianRepo.Remove(target);
             libRepo.Save();
             AuthenticateController.RemoveUser(target.UserName);
             if (target.UserName != HttpContext.User.Identity.Name.Substring(2))
             {
                 TempData["SuccessNoti"] = "Delete librarian " + target.UserName + " successfully.";
             }
             return RedirectToAction("Index");
     }
     return RedirectToAction("Index");
 }