public ActionResult AddUser(UserModel userModel,HttpPostedFileBase uploadFile)
        {
            ViewData["Roles"] = new List<string>(Enum.GetNames(typeof(Role))).AsEnumerable();
             if(ModelState.IsValid)
             {
             if (uploadFile != null)
             {
                 userModel.Photo = new byte[uploadFile.ContentLength];
                 uploadFile.InputStream.Read(userModel.Photo, 0, uploadFile.ContentLength);
             }
             var repository = Repository.GetRepository();
             var isUserAlreadyExist = repository.ExecuteScalar<int>("Select count(*) From t_user where UserName='******'");
             if(isUserAlreadyExist>0)
                 ModelState.AddModelError("UserAlreadyExists","User already exists.please enter a new user.");
             else
             {
                 var sqLiteParameters = new[]
                                            {
                                                new SQLiteParameter("@userName", DbType.String, 200)
                                                    {Value = userModel.UserName},
                                                new SQLiteParameter("@role", DbType.String, 20) {Value = userModel.Role}
                                                ,
                                                new SQLiteParameter("@photo", DbType.Binary, 20)
                                                    {Value = userModel.Photo},
                                                new SQLiteParameter("@gender", DbType.String, 20)
                                                    {Value = userModel.Gender}
                                            };

                 repository.ExecuteQuery("insert into t_user values(null,@userName,@role,@photo,@gender);",
                                         sqLiteParameters);

                 return RedirectToAction("ViewUsers");
             }
             }
            return View();
        }
        private List<UserModel> GetAllUserDetails()
        {
            var dataTable = Repository.GetRepository().LoadData("Select * from t_user");
            var userModels = new List<UserModel>();
            foreach (DataRow row in dataTable.Rows)
            {
                var userModel = new UserModel();
                userModel.UserName= row["UserName"] as string;
                userModel.Role= row["Role"] as string;
                userModel.Gender= row["Gender"] as string;
                userModel.Photo= row["Photo"] as Byte[];
                userModel.ID = Convert.ToInt32(row["PK_ID"]);
                userModels.Add(userModel);
            }

            return userModels;
        }
 private static bool isThesePairsInAnyCombination(UserModel pairTwo, UserModel pairOne, DataRow row)
 {
     return (Convert.ToString(row["PAIRONE"]) == pairOne.UserName && Convert.ToString(row["PAIRTWO"]) == pairTwo.UserName) ||
            (Convert.ToString(row["PAIRONE"]) == pairTwo.UserName && Convert.ToString(row["PAIRTWO"]) == pairOne.UserName);
 }