public void saveObjectable(List <Save_Object> saveObjects) { EventLog.WriteEntry("ICSNET", "Entered Save Objectable"); JICSBaseFacade <JCF_Answer> facade = new JICSBaseFacade <JCF_Answer>(); foreach (Save_Object obj in saveObjects) { JCF_Answer answer = (JCF_Answer)facade.GetQuery().Where(x => x.AnswerID.ToString() == obj.ID).FirstOrDefault(); answer.AnswerValue = (string)obj.Value; EventLog.WriteEntry("ICSNET", "Answer Value: " + answer.AnswerValue); facade.Save(answer); facade.Flush(); } EventLog.WriteEntry("ICSNET", "Exited Save Objectable"); }
private void readyViewObject(List <JCF_Submission> view_Objects, List <Guid> answer_Guids, Dictionary <Guid, object> question_Dictionary_List, Dictionary <Guid, string> question_Answer_Dictionary_List, Dictionary <Guid, string> question_Options_Dictionary_List) { JICSBaseFacade <JCF_FormItem> facade = new JICSBaseFacade <JCF_FormItem>(); JICSBaseFacade <JCF_Answer> answer_Facade = new JICSBaseFacade <JCF_Answer>(); int i = 0; Dictionary <int, string> type_Dictionary = new Dictionary <int, string> { { 0, "primary" }, { 1, "warning" }, { 2, "success" }, { 3, "danger" }, { 4, "info" } }; foreach (JCF_Submission view_Obj in view_Objects) { List <JCF_FormItem> questions = facade.GetQuery().Where(x => x.FormID == view_Obj.FormID).ToList(); //List<Abstract_Iter_able> results_Objects; //results_Objects = answer_Facade.GetByIdWhere(view_Obj.SubmissionID, "SubmissionID"); //List<JCF_FormItem> questions = new List<JCF_FormItem>(); /*foreach (JCF_FormItem question in form_items) * { * questions.Add(question); * * }*/ var ordered_form_items = questions.OrderBy(o => o.RowNum).ThenBy(o => o.QuestionNum); foreach (JCF_FormItem item in ordered_form_items) { if (item.IsActive) { //object_Options.Add(type_Dictionary[i % 5]); //question_Objects.Add(item); //List<string> query_Strings = new List<string>() { "SubmissionID", "ItemID" }; //List<object> query_Objects = new List<object>() { view_Obj.SubmissionID, item.ID }; List <JCF_Answer> items = answer_Facade.GetQuery().Where(x => x.SubmissionID == view_Obj.SubmissionID && x.ItemID == item.ID).ToList(); if (items.Count > 0) { //answer_Objects.Add(items[0]); JCF_Answer jCF_Answer = items[0]; question_Answer_Dictionary_List.Add(jCF_Answer.AnswerID, jCF_Answer.AnswerValue); question_Options_Dictionary_List.Add(jCF_Answer.AnswerID, type_Dictionary[i % 5]); question_Dictionary_List.Add(jCF_Answer.AnswerID, item); answer_Guids.Add(jCF_Answer.AnswerID); //question_Types.Add(item.Type.ToString()); } else { JCF_Answer new_Answer = new JCF_Answer(); new_Answer.SubmissionID = view_Obj.SubmissionID; new_Answer.ItemID = item.ID; new_Answer.AnswerValue = ""; new_Answer.AnswerID = Guid.NewGuid(); answer_Facade.Save(new_Answer); answer_Facade.Flush(); //answer_Objects.Add(new_Answer); question_Answer_Dictionary_List.Add(new_Answer.AnswerID, new_Answer.AnswerValue); question_Options_Dictionary_List.Add(new_Answer.AnswerID, type_Dictionary[i % 5]); question_Dictionary_List.Add(new_Answer.AnswerID, item); answer_Guids.Add(new_Answer.AnswerID); //question_Types.Add(item.Type.ToString()); } } } i++; } }