public static List <model.DapAn> convertListDapAnFromAnswaresText(string Answares) { List <model.DapAn> lsAnswares = new List <model.DapAn>(); try { string[] strAnswareSplits = Answares.Split(new string[] { "$#@$#@" }, StringSplitOptions.RemoveEmptyEntries); foreach (string Answare in strAnswareSplits) { string[] strSplitTemp = Answare.Split(new string[] { "!!!$$$" }, StringSplitOptions.RemoveEmptyEntries); int iIDTemp = -1; if (strSplitTemp.Length > 1 && int.TryParse(strSplitTemp[0].Trim(), out iIDTemp)) { model.DapAn DapAnTemp1 = new model.DapAn() { CauHoiID = int.Parse(strSplitTemp[0].Trim()), Match = strSplitTemp[1].Trim() }; lsAnswares.Add(DapAnTemp1); } } } catch { } return(lsAnswares); }
public static List <model.DapAn> convertListDapAnFromAnswares(string Answares, out List <int> lsDapAnIDs) { lsDapAnIDs = new List <int>(); List <model.DapAn> lsAnswares = new List <model.DapAn>(); string[] strAnswareSplits = Answares.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (string Answare in strAnswareSplits) { string[] strSplitTemp = Answare.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); int iIDTemp = -1; if (strSplitTemp.Length > 1 && int.TryParse(strSplitTemp[0].Trim(), out iIDTemp)) { model.DapAn DapAnTemp1 = new model.DapAn() { CauHoiID = int.Parse(strSplitTemp[0].Trim()), Match = strSplitTemp[1].Trim() }; lsAnswares.Add(DapAnTemp1); if (!lsDapAnIDs.Contains(iIDTemp)) { lsDapAnIDs.Add(iIDTemp); } } } return(lsAnswares); }