//private void EditBooleanConfigurationToUsers(Project project , string configurationName , string oldName) //{ // if (configurationName == oldName) // return; // foreach (var projectProjectUser in project.ProjectUsers) // { // foreach (var projectCustomData in project.ProjectCustomData.Where(m=> m.ConfigurationName == oldName)) // { // try // { // var userCustomData = // projectCustomData.UserCustomData.FirstOrDefault(m => m.UserId == projectProjectUser.UserId); // projectCustomData.UserCustomData.Remove(userCustomData); // userCustomData.ModificationDate = DateTime.UtcNow; // projectCustomData.UserCustomData.Add(userCustomData); // } // catch (Exception) // { // //ignore // } // } // } //} private void EditNumberConfigurationToUsers(NumberProjectConfiguration configuration, Project project, string configurationName) { var projectCustomData = project.ProjectCustomData.FirstOrDefault(m => m.ConfigurationName == configurationName); foreach (var userCustomData in projectCustomData.UserCustomData) { try { var userConfiguration = (NumberUserConfiguration) _jsonConvertService.DeserializeUser(ConfigurationType.Number, userCustomData.SerializedConfiguration); var userValueUpdateIsNeeded = (userConfiguration.Value < configuration.LowerBound) || (userConfiguration.Value > configuration.UpperBound); if (!userValueUpdateIsNeeded) { continue; } userConfiguration.Value = configuration.Default; userCustomData.SerializedConfiguration = _jsonConvertService.Serialize(userConfiguration); userCustomData.ModificationDate = DateTime.UtcNow; } catch (Exception) { //ignore } } }
public IActionResult SaveNumberCustomData(int projectId, NumberProjectConfiguration numberProjectConfiguration, string configurationName, Crud crudOption, string oldConfigurationName) { try { SaveConfiguration(projectId, numberProjectConfiguration, configurationName, crudOption, ConfigurationType.Number, 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 })); } }
private void AddNumberConfigurationToUsers(NumberProjectConfiguration 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 NumberUserConfiguration { Value = configuration.Default }) }); } }