private void EditTextConfigurationToUsers(TextProjectConfiguration configuration, Project project,
                                                  string configurationName)
        {
            var projectCustomData =
                project.ProjectCustomData.FirstOrDefault(m => m.ConfigurationName == configurationName);

            foreach (var userCustomData in projectCustomData.UserCustomData)
            {
                try
                {
                    var userConfiguration =
                        (TextUserConfiguration)
                        _jsonConvertService.DeserializeUser(ConfigurationType.Text,
                                                            userCustomData.SerializedConfiguration);

                    var userValueUpdateIsNeeded = !(configuration.PossibleValues.Contains(userConfiguration.Value) ||
                                                    (configuration.Default == userConfiguration.Value));

                    if (!userValueUpdateIsNeeded)
                    {
                        continue;
                    }

                    userConfiguration.Value = configuration.Default;
                    userCustomData.SerializedConfiguration = _jsonConvertService.Serialize(userConfiguration);
                    userCustomData.ModificationDate        = DateTime.UtcNow;
                }
                catch (Exception)
                {
                    //ignore
                }
            }
        }
 private void AddTextConfigurationToUsers(TextProjectConfiguration configuration, Project project,
                                          string configurationName)
 {
     foreach (var projectProjectUser in project.ProjectUsers)
     {
         var projectCustomData =
             project.ProjectCustomData.FirstOrDefault(m => m.ConfigurationName == configurationName);
         projectCustomData.UserCustomData.Add(new UserCustomData
         {
             UserId = projectProjectUser.UserId,
             SerializedConfiguration =
                 _jsonConvertService.Serialize(new TextUserConfiguration {
                 Value = configuration.Default
             })
         });
     }
 }
 public IActionResult SaveTextCustomData(int projectId, TextProjectConfiguration textProjectConfiguration,
                                         string configurationName,
                                         Crud crudOption, string oldConfigurationName)
 {
     try
     {
         if (textProjectConfiguration.PossibleValues.Contains(null))
         {
             textProjectConfiguration.PossibleValues.Remove(null);
         }
         SaveConfiguration(projectId, textProjectConfiguration, configurationName, crudOption,
                           ConfigurationType.Text, oldConfigurationName);
         Alert(AlertType.Success, "Data saved correctly.");
         return(RedirectToAction("GetById", "Projects", new { id = projectId }));
     }
     catch (Exception ex)
     {
         Alert(AlertType.Warning, ex.Message);
         return(RedirectToAction("GetById", "Projects", new { id = projectId }));
     }
 }