/// <summary> /// Delete Variable /// </summary> /// <param name="id"></param> /// <param name="Model"></param> public void Delete(Guid id) { var languageID = TSMContext.CurrentLanguageID; Variable variable = VariableService.GetVariable(id, languageID); if (variable != null) { List <Choice> choicelist = new List <Choice>(); choicelist = variable.Choices; variable.Choices = new List <Choice>(); variable.LastModifiedBy = TSM.Model.TSMContext.CurrentUser.ID; variable.LastModifiedDate = DateTime.UtcNow; variable.IsActive = false; variable.IsDeleted = true; variable.DisplayOrder = null; string Name = variable.Variable_Languages[0].Name; string DisplayName = variable.Variable_Languages[0].DisplayName; string Description = variable.Variable_Languages[0].Description; variable.Variable_Languages = new List <Variable_Language>(); variable.Variable_Languages.Add(new Variable_Language { ID = variable.ID, LanguageID = TSMContext.CurrentLanguageID, Name = Name, DisplayName = DisplayName, Description = Description }); variable.Choices = choicelist; VariableService.Save(variable, TSM.Model.TSMContext.CurrentSiteLanguageID); DeleteFromXML(id); } }
public Variable GetVariableFull(Guid id, Guid languageID) { try { variable = VariableService.GetVariable(id, languageID); variable.Choices = new List <Choice>(); variable.Variable_Languages = new List <Variable_Language>(); } catch (Exception ex) { ErrorLog.WriteLog("ManageVariableModel", "Populate", ex, ""); } return(variable); }
/// <summary> /// Populate Variable /// </summary> /// <param name="search"></param> /// public Variable GetVariable(Guid id, Guid languageID) { Variable variableinfo = new Variable(); try { variable = VariableService.GetVariable(id, languageID); if (variable != null && variable.Variable_Languages != null && variable.Variable_Languages.Count > 0) { this.ID = variableinfo.ID; this.Variable_Name = variable.Variable_Languages[0].Name; this.Variable_DisplayName = variable.Variable_Languages[0].DisplayName; this.Variable_Description = variable.Variable_Languages[0].Description; this.Is_AdvanceSearchFilter = variable.ShowInAdvancedSearchFilter; this.Variable_Type = variable.Type; this.ShowInDetailPage = variable.ShowInDetailPage; this.ShowInReport = variable.ShowInReport; this.IsActive = variable.IsActive; this.IsSystemDefined = variable.IsSytemDefined; this.FilterHeading = variable.FilterHeading; this.IsMandetory = variable.IsMandatory.Value; this.VariableCategory = variable.VariableCategory; this.ManageChoices = new List <SelectListItem>(); //var choices = variable.Choices.Select(c => c.Choice_Languages.Where(cls => cls.LanguageID == languageID)).ToList(); variable.Choices.Select(c => c.Choice_Languages).ToList().ForEach(cl => this.ManageChoices.Add( new SelectListItem() { Value = (cl[0].ID == null ? null : (cl[0].ID.ToString() + "/" + cl[0].Name.ToString())), Text = cl[0].Name, Selected = true })); } } catch (Exception ex) { ErrorLog.WriteLog("ManageVariableModel", "Populate", ex, ""); } return(variable); }
/// <summary> /// Update Variable Order /// </summary> /// <param name="id"></param> /// <param name="Model"></param> public void UpdateOrder(Dictionary <string, string> stepsDictionary) { foreach (var stepsdictionary in stepsDictionary) { Guid Id; try { Id = new Guid(stepsdictionary.Key); } catch { Id = Guid.Empty; } var languageID = TSMContext.CurrentLanguageID; Variable variable = VariableService.GetVariable(Id, languageID); if (variable != null) { int output; int.TryParse(stepsdictionary.Value, out output); List <Choice> choicelist = new List <Choice>(); choicelist = variable.Choices; variable.Choices = new List <Choice>(); variable.LastModifiedBy = TSM.Model.TSMContext.CurrentUser.ID; variable.LastModifiedDate = DateTime.UtcNow; variable.DisplayOrder = output; string Name = variable.Variable_Languages[0].Name; string DisplayName = variable.Variable_Languages[0].DisplayName; string Description = variable.Variable_Languages[0].Description; variable.Variable_Languages = new List <Variable_Language>(); variable.Variable_Languages.Add(new Variable_Language { ID = variable.ID, LanguageID = TSMContext.CurrentLanguageID, Name = Name, DisplayName = DisplayName, Description = Description }); variable.Choices = choicelist; VariableService.Save(variable, TSM.Model.TSMContext.CurrentSiteLanguageID); } } }