public static bool InsertUser(RegisterVModel userRegister)
        {
            using (var model = new fmDbDataModel())
            {
                try
                {
                    string hashedPassword = SecurityManager.CalculateHash(userRegister.Password);

                    fm_Users newUser = new fm_Users()
                    {
                        Name     = userRegister.Name,
                        Email    = userRegister.Email,
                        Password = hashedPassword,
                        Salt     = SecurityManager.GetSalt(), // later will be taken from database and fetched with new password to compare with the old one

                        InsertTime    = DateTime.Now,
                        AccountStatus = (int)AccountStatus.Active
                    };
                    // Adding the user to the currently connected database and now performing the same operation on the mirror ones.
                    model.fm_Users.Add(newUser);
                    model.SaveChanges();
                    DataOperationManager.Synch(new Func <RegisterVModel, bool>(InsertUser), new object[] { userRegister });

                    return(true);
                }
                catch (Exception e)
                {
                    DataOperationManager.VerifyResult(new Func <RegisterVModel, bool>(InsertUser), new object[] { userRegister }, MethodReturnStatus.Error);
                    _log.ErrorFormat("There was an error with inserting user to db. Message: {0}, Stacktrace: {1}", e.Message, e.StackTrace);
                    return(false);
                }
            }
        }
        public static void SwitchCurrency(CurrencyType?currency)
        {
            if (currency == null)
            {
                return;
            }

            using (var model = new fmDbDataModel())
            {
                try
                {
                    if (HttpContext.Current.Session["USER_ID"] != null)
                    {
                        long userId = Convert.ToInt64(HttpContext.Current.Session["USER_ID"].ToString());
                        var  user   = model.fm_Users.FirstOrDefault(u => u.Id == userId);
                        if (user != null)
                        {
                            UserSingleton.Instance.DefaultCurrency = (int)currency;
                            user.DefaultCurrency = (int)currency;
                            model.SaveChanges();
                            DataOperationManager.Synch(new Action <CurrencyType?>(SwitchCurrency), new object[] { currency });
                        }
                        else
                        {
                            DataOperationManager.VerifyResult(new Action <CurrencyType?>(SwitchCurrency), new object[] { currency }, MethodReturnStatus.Null);
                        }
                    }
                }
                catch (Exception e)
                {
                    DataOperationManager.VerifyResult(new Action <CurrencyType?>(SwitchCurrency), new object[] { currency }, MethodReturnStatus.Error);
                    _log.ErrorFormat("There was an error with inserting user to db. Message: {0}, Stacktrace: {1}", e.Message, e.StackTrace);
                }
            }
        }