public ActionResult Create(UpsertBlacklistUserViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    UserBlackList newBlacklistUser = new UserBlackList();

                    newBlacklistUser.clanUserId = model.ClanUserId;
                    newBlacklistUser.clanId = (int)ClanManager.GetClanId(User.Identity.GetUserId());
                    newBlacklistUser.note = model.Notes;

                    BlacklistManager.Insert(newBlacklistUser);

                    ClanUser blUser = ClanUserManager.SelectByClanUserId(model.ClanUserId);
                    blUser.clanId = null;
                    ClanUserManager.Update(blUser);
                }
            }
            catch
            {
                return View(new UpsertBlacklistUserViewModel());
            }

            return RedirectToAction("EditMode","Members");
        }
 /// <summary>
 /// Inserts a new UserBlackList record
 /// </summary>
 public static void Insert(UserBlackList bUser)
 {
     using (var dbContext = new HouseOfClansEntities())
     {
         bUser.addedOn = DateTime.Now;
         dbContext.UserBlackLists.Add(bUser);
         dbContext.SaveChanges();
     }
 }
        /// <summary>
        /// Gets a UserBlacklist based on the blacklist id
        /// </summary>
        /// <param name="userBlacklistId">UserBlacklist Id</param>
        public static UserBlackList SelectByBlacklistId(int blacklistId)
        {
            UserBlackList blacklist = new UserBlackList();

            using (var dbContext = new HouseOfClansEntities())
            {
                blacklist = dbContext.UserBlackLists.Where(p => p.id == blacklistId).FirstOrDefault();
            }

            return blacklist;
        }
 /// <summary>
 /// Updates a UserBlackList
 /// </summary>
 public static void Update(UserBlackList updatedBUser)
 {
     UserBlackList bUser = BlacklistManager.SelectByBlacklistId(updatedBUser.id);
     using (var dbContext = new HouseOfClansEntities())
     {
         //TODO: Add updatedOn for the UserBlackList entity in the database
         //updatedBUser.updatedOn = DateTime.Now;
         dbContext.UserBlackLists.Attach(bUser);
         dbContext.Entry(bUser).CurrentValues.SetValues(updatedBUser);
         dbContext.SaveChanges();
     }
 }