/// <summary> /// Add new question /// </summary> /// <param name="questionDTO"></param> /// <returns></returns> public QuestionDTO Add(QuestionDTO questionDTO) { try { questionDTO.Id = Guid.NewGuid(); questionDTO.UploadDate = DateTime.Now; questionDTO.EditDate = questionDTO.UploadDate; return(questionData.Add(questionDTO)); } catch (NoSuchUserExists) { throw new NoSuchUserExists(); } catch { return(null); } }
//public string plusImg = "plus.png"; //public Image _plusImage { get; set; } = plusImg.so; //public Image plusImage //{ // get { return _plusImage; } // set // { // _plusImage = value; // OnPropertyChanged("plusImage"); // } //} public async Task FetchCommnetData(int requirementId) { using (HttpClient hc = new HttpClient()) { try { IsBusy = true; var httpClient = new HttpClient(); var response = await hc.GetStringAsync(Config.COMMENT_INFO_URL + requirementId); var obj = JsonConvert.DeserializeObject <CommentsInfoModel>(response); if (obj != null) { officerName = obj.primaryOfficer; statusDec = obj.statusDescription; initiateProcessIdTxt = obj.initiateProcessId; statusTxt = obj.status; assignedToFullNameTxt = obj.assignedToFullName; processIdTxt = obj.processId; stageIdTxt = obj.stageId; threadId = obj.threadId; threadTitle = obj.threadTitle; if (obj.reqQuestionDefinitions.Count != 0) { isQuestionAvailable = true; isPlusVisible = true; IsStackExpanded = true; IsExpanderActive = true; QuestionsListHeight = 90; foreach (var item in obj.reqQuestionDefinitions) { QuestionsListHeight = QuestionsListHeight * obj.reqQuestionDefinitions.Count; if (item.actualValueBit != null) { switch (item.actualValueBit.Trim().ToUpper()) { case "TRUE": item.actualValueBit = "Yes"; break; case "FALSE": item.actualValueBit = "No"; break; } } if (item.expectedValueLowBit != null) { switch (item.expectedValueLowBit.Trim().ToUpper()) { case "TRUE": item.expectedValueLowBit = "Yes"; break; case "FALSE": item.expectedValueLowBit = "No"; break; } } if (item.actualValueDate != null) { switch (item.actualValueDate.Trim().ToUpper()) { case "TRUE": item.actualValueDate = "Yes"; break; case "FALSE": item.actualValueDate = "No"; break; } } if (item.expectedValueLowDate != null) { switch (item.expectedValueLowDate.Trim().ToUpper()) { case "TRUE": item.expectedValueLowDate = "Yes"; break; case "FALSE": item.expectedValueLowDate = "No"; break; } } if (item.actualValueDecimal != null) { switch (item.actualValueDecimal.Trim().ToUpper()) { case "TRUE": item.actualValueDecimal = "Yes"; break; case "FALSE": item.actualValueDecimal = "No"; break; } } if (item.expectedValueLowDecimal != null) { switch (item.expectedValueLowDecimal.Trim().ToUpper()) { case "TRUE": item.expectedValueLowDecimal = "Yes"; break; case "FALSE": item.expectedValueLowDecimal = "No"; break; } } if (item.actualValueInt != null) { switch (item.actualValueInt.Trim().ToUpper()) { case "TRUE": item.actualValueInt = "Yes"; break; case "FALSE": item.actualValueInt = "No"; break; } } if (item.expectedValueLowInt != null) { switch (item.expectedValueLowInt.Trim().ToUpper()) { case "TRUE": item.expectedValueLowInt = "Yes"; break; case "FALSE": item.expectedValueLowInt = "No"; break; } } if (item.actualValuePercent != null) { switch (item.actualValuePercent.Trim().ToUpper()) { case "TRUE": item.actualValuePercent = "Yes"; break; case "FALSE": item.actualValuePercent = "No"; break; } } if (item.expectedValueLowPercent != null) { switch (item.expectedValueLowPercent.Trim().ToUpper()) { case "TRUE": item.expectedValueLowPercent = "Yes"; break; case "FALSE": item.expectedValueLowPercent = "No"; break; } } if (item.actualValueText != null) { switch (item.actualValueText.Trim().ToUpper()) { case "TRUE": item.actualValueText = "Yes"; break; case "FALSE": item.actualValueText = "No"; break; } } if (item.expectedValueLowVarchar != null) { switch (item.expectedValueLowVarchar.Trim().ToUpper()) { case "TRUE": item.expectedValueLowVarchar = "Yes"; break; case "FALSE": item.expectedValueLowVarchar = "No"; break; } } if (item.expectedValueLowOperand == "=") { Operand = ""; } else { Operand = item.expectedValueLowOperand; } if (item.dataType == "bool") { item.actualValue = "Actual : " + item.actualValueBit; item.expectedValue = "Expected : " + Operand + item.expectedValueLowBit.ToString(); } else if (item.dataType == "int") { item.actualValue = "Actual: " + item.actualValueInt; item.expectedValue = "Expected: " + Operand + item.expectedValueLowInt; } else if (item.dataType == "text") { item.actualValue = "Actual: " + item.actualValueText; item.expectedValue = "Expected: " + Operand + item.expectedValueLowVarchar; } else if (item.dataType == "percent") { item.actualValue = "Actual: " + item.actualValuePercent; item.expectedValue = "Expected: " + Operand + item.expectedValueLowPercent; } else if (item.dataType == "decimal") { item.actualValue = "Actual: " + item.actualValueDecimal; item.expectedValue = "Expected: " + Operand + item.expectedValueLowDecimal; } else { item.actualValue = "Actual: " + item.actualValueDate; item.expectedValue = "Expected: " + Operand + item.expectedValueLowDate; } QuestionData.Add(item); } } else { isPlusVisible = false; IsStackExpanded = false; IsExpanderActive = false; isQuestionAvailable = false; } if (obj.isSubjectTo == null || obj.isSubjectTo == "false") { isSubjectToVisible = false; } else { isSubjectToVisible = true; subjectTo = obj.subjectTo; } if (obj.isMitigatingFactors == null || obj.isMitigatingFactors == "false") { isMitigatingVisible = false; } else { isMitigatingVisible = true; MitigatingFactors = obj.mitigatingFactors; } if (obj.comment == null) { commnetsVisible = false; } else { commnetsVisible = true; comments = obj.comment; } if (obj.lastMessage == null && obj.lastPostBy == null && obj.lastPostDate == null) { sendMessageVisible = false; } else { sendMessageVisible = true; senderName = obj.lastPostBy; SubjectDec = obj.lastMessage; sendingDate = DateTime.Parse(obj.lastPostDate, new CultureInfo("en-US", true)); } needsExceptionActions = "false"; primaryDocumentException = "false"; if (obj.exception == "true" || (obj.requireDocument == true && obj.missingDocument == true)) { needsExceptionActions = "true"; if (obj.requireDocument == true && obj.missingDocument == true) { primaryDocumentException = "true"; } } else if (obj.showCompareFlag == "1" && obj.actualValue == null) { needsExceptionActions = null; } if (obj.exception != null && obj.exceptionFlag == "false" && primaryDocumentException == "false") { needsExceptionActions = "false"; } GetPendingApprovalJSON(); } } catch (Exception e) { Debug.WriteLine(e.Message); return; } finally { IsBusy = false; } } }
public async Task FetchCommnetData(int requirementId) { using (HttpClient hc = new HttpClient()) { try { IsBusy = true; var httpClient = new HttpClient(); var response = await hc.GetStringAsync(Config.COMMENT_INFO_URL + requirementId); var obj = JsonConvert.DeserializeObject <CommentsInfoModel>(response); if (obj != null) { officerName = obj.primaryOfficer; statusDec = obj.statusDescription; initiateProcessIdTxt = obj.initiateProcessId; statusTxt = obj.status; assignedToFullNameTxt = obj.assignedToFullName; processIdTxt = obj.processId; stageIdTxt = obj.stageId; threadId = obj.threadId; threadTitle = obj.threadTitle; if (obj.reqQuestionDefinitions.Count != 0) { isPlusVisible = true; isQuestionAvailable = true; foreach (var item in obj.reqQuestionDefinitions) { if (item.actualValueBit != null) { switch (item.actualValueBit.Trim().ToUpper()) { case "TRUE": item.actualValueBit = "Yes"; break; case "FALSE": item.actualValueBit = "No"; break; } } if (item.expectedValueLowBit != null) { switch (item.expectedValueLowBit.Trim().ToUpper()) { case "TRUE": item.expectedValueLowBit = "Yes"; break; case "FALSE": item.expectedValueLowBit = "No"; break; } } if (item.actualValueDate != null) { switch (item.actualValueDate.Trim().ToUpper()) { case "TRUE": item.actualValueDate = "Yes"; break; case "FALSE": item.actualValueDate = "No"; break; } } if (item.expectedValueLowDate != null) { switch (item.expectedValueLowDate.Trim().ToUpper()) { case "TRUE": item.expectedValueLowDate = "Yes"; break; case "FALSE": item.expectedValueLowDate = "No"; break; } } if (item.actualValueDecimal != null) { switch (item.actualValueDecimal.Trim().ToUpper()) { case "TRUE": item.actualValueDecimal = "Yes"; break; case "FALSE": item.actualValueDecimal = "No"; break; } } if (item.expectedValueLowDecimal != null) { switch (item.expectedValueLowDecimal.Trim().ToUpper()) { case "TRUE": item.expectedValueLowDecimal = "Yes"; break; case "FALSE": item.expectedValueLowDecimal = "No"; break; } } if (item.actualValueInt != null) { switch (item.actualValueInt.Trim().ToUpper()) { case "TRUE": item.actualValueInt = "Yes"; break; case "FALSE": item.actualValueInt = "No"; break; } } if (item.expectedValueLowInt != null) { switch (item.expectedValueLowInt.Trim().ToUpper()) { case "TRUE": item.expectedValueLowInt = "Yes"; break; case "FALSE": item.expectedValueLowInt = "No"; break; } } if (item.actualValuePercent != null) { switch (item.actualValuePercent.Trim().ToUpper()) { case "TRUE": item.actualValuePercent = "Yes"; break; case "FALSE": item.actualValuePercent = "No"; break; } } if (item.expectedValueLowPercent != null) { switch (item.expectedValueLowPercent.Trim().ToUpper()) { case "TRUE": item.expectedValueLowPercent = "Yes"; break; case "FALSE": item.expectedValueLowPercent = "No"; break; } } if (item.actualValueText != null) { switch (item.actualValueText.Trim().ToUpper()) { case "TRUE": item.actualValueText = "Yes"; break; case "FALSE": item.actualValueText = "No"; break; } } if (item.expectedValueLowVarchar != null) { switch (item.expectedValueLowVarchar.Trim().ToUpper()) { case "TRUE": item.expectedValueLowVarchar = "Yes"; break; case "FALSE": item.expectedValueLowVarchar = "No"; break; } } if (item.expectedValueLowOperand == "=") { Operand = ""; } else { Operand = item.expectedValueLowOperand; } if (item.dataType == "bool") { item.actualValue = "Actual : " + item.actualValueBit; item.expectedValue = "Expected : " + Operand + item.expectedValueLowBit.ToString(); } else if (item.dataType == "int") { item.actualValue = "Actual: " + item.actualValueInt; item.expectedValue = "Expected: " + Operand + item.expectedValueLowInt; } else if (item.dataType == "text") { item.actualValue = "Actual: " + item.actualValueText; item.expectedValue = "Expected: " + Operand + item.expectedValueLowVarchar; } else if (item.dataType == "percent") { item.actualValue = "Actual: " + item.actualValuePercent; item.expectedValue = "Expected: " + Operand + item.expectedValueLowPercent; } else if (item.dataType == "decimal") { item.actualValue = "Actual: " + item.actualValueDecimal; item.expectedValue = "Expected: " + Operand + item.expectedValueLowDecimal; } else { item.actualValue = "Actual: " + item.actualValueDate; item.expectedValue = "Expected: " + Operand + item.expectedValueLowDate; } QuestionData.Add(item); } } else { isPlusVisible = false; isQuestionAvailable = false; } if (obj.isSubjectTo == null || obj.isSubjectTo == "false") { isSubjectToVisible = false; } else { isSubjectToVisible = true; if (obj.subjectTo.Contains("\n")) { subjectTo = obj.subjectTo.Replace("\n", "</br>"); } else { subjectTo = obj.subjectTo; } } if (obj.isMitigatingFactors == null || obj.isMitigatingFactors == "false") { isMitigatingVisible = false; } else { isMitigatingVisible = true; if (obj.mitigatingFactors.Contains("\n")) { MitigatingFactors = obj.mitigatingFactors.Replace("\n", "</br>"); } else { MitigatingFactors = obj.mitigatingFactors; } } if (obj.comment == null) { commnetsVisible = false; } else { commnetsVisible = true; if (obj.comment.Contains("\n")) { comments = obj.comment.Replace("\n", "</br>"); } else { comments = obj.comment; } } if (obj.lastMessage == null && obj.lastPostBy == null && obj.lastPostDate == null) { sendMessageVisible = false; } else { sendMessageVisible = true; senderName = obj.lastPostBy; sendingDate = DateTime.Parse(obj.lastPostDate, new CultureInfo("en-US", true)); if (obj.lastMessage.Contains("data:image")) { var image = obj.lastMessage.Split(',')[1]; var image1 = image.Split('"')[0]; string[] delim = { "alt=\"\">" }; var stringMsg = image.Split(delim, StringSplitOptions.None); var Base64Stream = Convert.FromBase64String(image1); MsgImageUrl = ImageSource.FromStream(() => new MemoryStream(Base64Stream)); displayImage = MsgImageUrl; IsImageVisible = true; if (!string.IsNullOrEmpty(stringMsg[1])) { SubjectDec = stringMsg[1]; } else { SubjectDec = string.Empty; } } else { IsImageVisible = false; SubjectDec = obj.lastMessage; } } needsExceptionActions = "false"; primaryDocumentException = "false"; if (obj.exception == "true" || (obj.requireDocument == true && obj.missingDocument == true)) { needsExceptionActions = "true"; if (obj.requireDocument == true && obj.missingDocument == true) { primaryDocumentException = "true"; } } else if (obj.showCompareFlag == "1" && obj.actualValue == null) { needsExceptionActions = null; } if (obj.exception != null && obj.exceptionFlag == "false" && primaryDocumentException == "false") { needsExceptionActions = "false"; } GetPendingApprovalJSON(); } } catch (Exception e) { Debug.WriteLine(e.Message); return; } finally { IsBusy = false; } } }