Exemplo n.º 1
0
        /// <summary>
        /// this function will update a complete settings list for a given user
        /// </summary>
        /// <param name="user">the given user</param>
        /// <param name="settings">the complete settings list</param>
        public void UpdateSettingsValueForUser(User user, List <Setting> settings)
        {
            #region Log Action
            //the specific log action
            String logAction = $"Actualizat valoarea tuturor setarilor pentru utilizatorul {user.DisplayName}";
            //we use the string builder to make the command faster
            StringBuilder commandBuilder = new StringBuilder(250 * settings.Count);
            //we generate the Computer IP
            String IP = Miscellaneous.IPFunctions.GetWANIp();
            #endregion

            foreach (Setting setting in settings)
            {
                #region Action Log
                //we generate the log command for each inser command
                commandBuilder.Append("UPDATE setari_utilizatori " +
                                      $"SET valoare_setare = {setting.Value} " +
                                      $"WHERE utilizator_id = {user.ID} AND setare_id = {setting.ID}");
                #endregion
                SetariUtilizatori setareUtilizator = base.SetariUtilizatori.Where(element => element.UtilizatorId == user.ID && element.SetareId == setting.ID).FirstOrDefault();
                setareUtilizator.ValoareSetare = setting.GetStringValue;
                base.Update(setareUtilizator);
            }

            base.LogActiuni.Add(ActionLog.LogAction(logAction, IP, commandBuilder.ToString()));
        }
Exemplo n.º 2
0
 /// <summary>
 /// this function will update a solitary setting with the new setting value for a given user
 /// </summary>
 /// <param name="user">the given user</param>
 /// <param name="setting">the setting</param>
 public void UpdateSettingValueForUser(User user, Setting setting)
 {
     #region Log Action
     //the specific log action
     String logAction = $"Actualizat valoarea setarii {setting.SettingDisplay} pentru utilizatorul {user.DisplayName}";
     //we generate the log Command
     String logCommand = "UPDATE setari_utilizatori " +
                         $"SET valoare_setare = {setting.GetStringValue} " +
                         $"WHERE utilizator_id = {user.ID} AND setare_id = {setting.ID}";
     //we generate the Computer IP
     String IP = MentorBilling.Miscellaneous.IPFunctions.GetWANIp();
     #endregion
     SetariUtilizatori setareUtilizator = base.SetariUtilizatori.Where(element => element.UtilizatorId == user.ID && element.SetareId == setting.ID).FirstOrDefault();
     setareUtilizator.ValoareSetare = setting.GetStringValue;
     base.Update(setareUtilizator);
     base.LogActiuni.Add(ActionLog.LogAction(logAction, IP, logCommand));
     base.SaveChanges();
 }