/// <summary> /// Сохранить вопрос пользователя. /// </summary> /// <param name="question">Сохраняемый вопрос пользователя.</param> /// <returns>Сохраненный вопрос пользователя с заполненным идентификатором</returns> public Guid Save(QuestionBase question) { using (var uow = CreateUnitOfWork()) { return(uow.QuestionRepository.Save(question)); } }
public void CreateModel_CreatesModelOfCorrectType_CreatesModelMetaDataOfCorrectQuestionType() { // Arrange var formCollection = new NameValueCollection { // MaritalStatus here provides better test experience over CurrentLienHolder // since CurrentLienHolder is a default value for Enum.TryParse(questionDefinitionIdName { "QuestionDefinitionId", "MaritalStatus" } }; var valueProvider = new NameValueCollectionValueProvider(formCollection, null); var modelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(QuestionBase)); var bindingContext = new ModelBindingContext { ModelName = "", ValueProvider = valueProvider, ModelMetadata = modelMetadata }; QuestionBaseModelBinder b = new QuestionBaseModelBinder(); ControllerContext controllerContext = new ControllerContext(); // Act QuestionBase result = (QuestionBase)b.BindModel(controllerContext, bindingContext); // Assert Assert.AreEqual(result.QuestionDefinitionId, QuestionDefinitionId.MaritalStatus); }
// GET: Questions/Edit/ public ActionResult Edit(Guid questionnaireId, QuestionDefinitionId?questionDefinitionId) { QuestionDefinitionId questionDefinitionIdToEdit; if (questionDefinitionId.HasValue) { questionDefinitionIdToEdit = questionDefinitionId.Value; } else { questionDefinitionIdToEdit = _questionDefinitionService.FirstDefinitionId; } QuestionBase question = _repository.Find(questionnaireId, questionDefinitionIdToEdit); if (question == null) { // Create the question if we can't find it in the Repository return(RedirectToAction("Create", new { questionnaireId = questionnaireId, questionDefinitionId = questionDefinitionIdToEdit })); } var questionDefinition = _questionDefinitionService.GetDefinition(questionDefinitionIdToEdit); ViewBag.questionDefinition = questionDefinition; return(View(question)); }
public ActionResult Edit([Bind(Include = "EmployerNameValue,PositionTitleValue,AddressValue,DebtorValue," + "AmountOwedValue,MonthlyPaymentValue,NameValue,EmailValue,PhoneValue," + "CurrencyValue,MonthValue,YearValue,DateValue,IntValue,SelectedAnswers," + "SelectedAnswer,StreetValue,CityValue,StateValue,ZipValue," + "StringValue,Id,QuestionDefinitionId,QuestionnaireId," + "MonthDurationValue,YearDurationValue")] QuestionBase question) { if (ModelState.IsValid) { _repository.Update(question); _repository.Save(); var currentQuestion = _questionDefinitionService.GetDefinition(question.QuestionDefinitionId); var nextQuestionId = currentQuestion.GetNextQuestionId(question); if (!nextQuestionId.HasValue) { return(RedirectToAction("Index", "Questionnaires")); } else { return(RedirectToAction("Edit", new { questionnaireId = question.QuestionnaireId, questionDefinitionId = nextQuestionId })); } } return(View(question)); }
private QuestionClosedAnswerVm MapModelToQuestion(QuestionBase question) { if (question is QuestionClosedAnswer) { return(this.MapModelToQuestionClosedAnswer((QuestionClosedAnswer)question)); } return(null); }
public QuestionBase AddQuestion(string questionText) { if (survey == null) { throw new ArgumentException("Survey not inited! Call method CreateSurvey first!"); } QuestionBase question = new QuestionBase(lastQuestionId++, questionText); survey.AddQuestion(question); return(question); }
public AnswerBase AddAnswer(QuestionBase question, string answerText, bool isCorrect) { int maxAnswerId = 0; if (question.GetAnswers().Count > 0) { maxAnswerId = question.GetAnswers().Max(x => x.Id); } var answer = new AnswerBase(maxAnswerId + 1, answerText, isCorrect); question.AddAnswer(answer); return(answer); }
public void AnswerBy_ShouldReturnCorrectValue( QuestionBase <Ability1, object> sut, IActor actor, object expected) { //arrange #pragma warning disable CS0618 // Type or member is obsolete Mock.Get(actor).Setup(a => a.AsksForWithAbility(sut)).Returns(expected); #pragma warning restore CS0618 // Type or member is obsolete //act var actual = sut.AnsweredBy(actor); //assert actual.Should().Be(expected); }
public void AddQuestion(QuestionBase question) { question.Index = Questions.Count; if (question is OpenText) { question.QuestionType = QuestionBase.Type.OpenText; } else if (question is MultipleChoice) { question.QuestionType = QuestionBase.Type.MultipleChoice; } Questions.Add(question); }
public void AnswerByWithAbility_ShouldReturnCorrectValue( QuestionBase <object> sut, IActor actor, object expected) { //arrange Mock.Get(sut).Protected() .Setup <object>("Answer", ItExpr.Is <IActor>(a => a == actor)) .Returns(expected); //act var actual = sut.AnsweredBy(actor); //assert actual.Should().Be(expected); }
internal void Insert(int index, QuestionBase item) { _questions.Insert(index, item); }
public virtual QuestionDefinitionId?GetNextQuestionId(QuestionBase question) { // Just return default for all usual cases. return(_defaultNextQuestionId); }
private QuestionBase <string> GetQuestion(GrpcQuestionBase grpcQuestion) { var question = new QuestionBase <string>() { Key = grpcQuestion.Key, Order = grpcQuestion.Order, Checked = grpcQuestion.Checked, AfterBox = grpcQuestion.AfterBox, Label = grpcQuestion.Label, MethodName = grpcQuestion.MethodName, QuestionsKey = grpcQuestion.QuestionsKey, Value = grpcQuestion.Value, ControlType = (ControlType)grpcQuestion.ControlType, Type = (InputType)grpcQuestion.Type, Validator = GetQuestionValidator(grpcQuestion.Validator) }; if (grpcQuestion.Options != null) { var options = new List <QuestionOption>(); options.AddRange(grpcQuestion.Options.Select(o => GetQuestionOption(o))); question.Options = options; } switch (grpcQuestion.SelectedFromCase) { case GrpcQuestionBase.SelectedFromOneofCase.SelectedFromInt: question.SelectedFrom = grpcQuestion.SelectedFromInt; break; case GrpcQuestionBase.SelectedFromOneofCase.SelectedFromDouble: question.SelectedFrom = grpcQuestion.SelectedFromDouble; break; case GrpcQuestionBase.SelectedFromOneofCase.SelectedFromDecimal: question.SelectedFrom = CustomTypes.DecimalValue.GetDecimal(grpcQuestion.SelectedFromDecimal); break; } switch (grpcQuestion.SelectedToCase) { case GrpcQuestionBase.SelectedToOneofCase.SelectedToInt: question.SelectedTo = grpcQuestion.SelectedToInt; break; case GrpcQuestionBase.SelectedToOneofCase.SelectedToDouble: question.SelectedTo = grpcQuestion.SelectedToDouble; break; case GrpcQuestionBase.SelectedToOneofCase.SelectedToDecimal: question.SelectedTo = CustomTypes.DecimalValue.GetDecimal(grpcQuestion.SelectedToDecimal); break; } switch (grpcQuestion.FromCase) { case GrpcQuestionBase.FromOneofCase.FromInt: question.From = grpcQuestion.FromInt; break; case GrpcQuestionBase.FromOneofCase.FromDouble: question.From = grpcQuestion.FromDouble; break; case GrpcQuestionBase.FromOneofCase.FromDecimal: question.From = CustomTypes.DecimalValue.GetDecimal(grpcQuestion.FromDecimal); break; } switch (grpcQuestion.ToCase) { case GrpcQuestionBase.ToOneofCase.ToInt: question.To = grpcQuestion.ToInt; break; case GrpcQuestionBase.ToOneofCase.ToDouble: question.To = grpcQuestion.ToDouble; break; case GrpcQuestionBase.ToOneofCase.ToDecimal: question.To = CustomTypes.DecimalValue.GetDecimal(grpcQuestion.ToDecimal); break; } return(question); }
/// <summary> /// Set Document Upload Control /// </summary> /// <param name="item"></param> private void SetDocumentUploadControl(QuestionBase item) { rbDocUploadYes.Checked = item.IsDocumentUpload; rbDocUploadNo.Checked = !item.IsDocumentUpload; }
/// <summary> /// Set Allow Comment Control /// </summary> /// <param name="item"></param> private void SetAllowCommentControl(QuestionBase item) { rbAllowCommentYes.Checked = item.IsAllowComments; rbAllowCommentNo.Checked = !item.IsAllowComments; }
public Guid Save([FromBody] QuestionBase question) { return(QuestionService.Save(question)); }
public static void InsertQuestionTypeAction(QuestionBase q) { }
private void LoadData() { if (Tile.TileParms.GetParm("item") == null) return; _questionType = Tile.TileParms.GetParm("item").GetType(); if (_questionType.Name == "BankQuestion") { _oBankQuestion = (BankQuestion)Tile.TileParms.GetParm("item"); _oQuestionBase = (QuestionBase)_oBankQuestion; } else { _oTestQuestion = (TestQuestion)Tile.TileParms.GetParm("item"); _oQuestionBase = (QuestionBase)_oTestQuestion; } var dparms = DistrictParms.LoadDistrictParms(); ItemContentTile_lbl_OTCUrl.Value = AppSettings.OTCUrl + dparms.ClientID; ItemContentTile_itemID.Value = _oQuestionBase.ID.ToString(); ItemContentTile_itemType.Value = _questionType.Name.ToString(); /* set up our image element to point * to the item's thumbnail image */ var imgFilePath = AppSettings.ItemThumbnailWebPath_Content + _oQuestionBase.ThumbnailName; if (!System.IO.File.Exists(Server.MapPath(imgFilePath))) imgFilePath = "~/Images/thumb_none.png"; ItemContentTile_imgThumbnail.Src = imgFilePath; /* determine size of image. If it is smaller * than the space we allow, then increase its * height or width. If it is larger than the * space we allow, then use max-width and max * height to shrink it. */ System.Drawing.Image imgThumbNail = System.Drawing.Image.FromFile(Server.MapPath(imgFilePath)); var fImgHeight = imgThumbNail.PhysicalDimension.Height; var fImgWidth = imgThumbNail.PhysicalDimension.Width; var lImgTagMaxHeight = DataIntegrity.ConvertToNullableFloat(ItemContentTile_imgThumbnail.Style["max-height"].ToString().Replace("px","").Replace("%","")); var lImgTagMaxWidth = DataIntegrity.ConvertToNullableFloat(ItemContentTile_imgThumbnail.Style["max-width"].ToString().Replace("px", "").Replace("%", "")); if (fImgHeight < lImgTagMaxHeight && fImgWidth < lImgTagMaxWidth) { if (fImgHeight > fImgWidth) ItemContentTile_imgThumbnail.Height = DataIntegrity.ConvertToInt(lImgTagMaxHeight); else ItemContentTile_imgThumbnail.Width = DataIntegrity.ConvertToInt(lImgTagMaxWidth); } /* Set up our online preview link's onClick * event with the item's ID. */ ItemContentTile_hdnThumbnailURL.Value = @"display.asp?formatoption=search results&key=9120&retrievemode=searchpage&ahaveSkipped=normal&??Question=" + _oQuestionBase.ID.ToString() + @"&??TestID=0&qreview=y"; imgPreviewIcon.Src = ResolveUrl("../../Images/preview_small.png"); /* Set up our Print Preview hidden text box * to hold the encrypted ID of the item */ ItemContentTile_hdnPrintPreviewInfo.Value = ResolveUrl("../../Record/RenderItemAsPDF.aspx?xID=") + Encryption.EncryptString(_oQuestionBase.ID.ToString()) + "&TestQuestion=" + Encryption.EncryptString((_questionType.Name=="BankQuestion") ? "false" : "true"); imgPrintPreviewIcon.Src = ResolveUrl("../../Images/mag_glass.png"); /* See if the item has an addendum. If so then * set up and display link to pop up Addendum. * Otherwise make sure it doesn't display.*/ if (_oQuestionBase.AddendumID == 0) { divDisplayAddendum.Style["visibility"] = "hidden"; } else { if (_questionType.Name == "BankQuestion") _oBankQuestion.LoadAddendum(); //_oQuestionBase.LoadAddendum(); hlLaunchAddendumPage.InnerText = _oQuestionBase.Addendum.Addendum_Name; hlLaunchAddendumPage.Attributes["onClick"] = "window.open('" + ResolveUrl("../../Record/AddendumPage.aspx?xID=") + Encryption.EncryptString(_oQuestionBase.AddendumID.ToString()) + "'); return false;"; divAddendumContent.InnerHtml = _oQuestionBase.Addendum.Addendum_Text; hlDisplayAddendum.Attributes["onClick"] = "displayAddendumClick();"; HtmlImage imgAddendumIcon = new HtmlImage(); imgAddendumIcon.ID = "imgAddendumIcon"; imgAddendumIcon.Src = ResolveUrl("../../Images/Addendum_small.png"); imgAddendumIcon.Height = 20; hlDisplayAddendum.Controls.Add(imgAddendumIcon); Label lblAddendum_Name = new Label(); lblAddendum_Name.Text = _oQuestionBase.Addendum.Addendum_Name; hlDisplayAddendum.Controls.Add(lblAddendum_Name); //hlDisplayAddendum.InnerText = oItem.Addendum.Addendum_Name; divDisplayAddendum.Style["visibility"] = "visible"; } }
public bool Contains(QuestionBase q1) { return _questions.Contains(q1); }
private void LoadData() { if (Tile.TileParms.GetParm("item") == null) return; _questionType = Tile.TileParms.GetParm("item").GetType(); if (_questionType.Name == "BankQuestion") { _oBankQuestion = (BankQuestion) Tile.TileParms.GetParm("item"); _oQuestionBase = (QuestionBase) _oBankQuestion; } else { _oTestQuestion = (TestQuestion) Tile.TileParms.GetParm("item"); _oQuestionBase = (QuestionBase) _oTestQuestion; } lblGrade.Text = _oQuestionBase.Grade; lblSubject.Text = _oQuestionBase.Subject; lblItemBanks.Text = ItemBankMasterList.Filtered_ItemBank_Labels(_oQuestionBase.ItemBankList, SessionObject.LoggedInUser); lblStatus.Text = _oQuestionBase.Status; lblReservation.Text = _oQuestionBase.Reservation; lblAnchorItem.Text = _oQuestionBase.IsAnchorItem ? "Yes" : "No"; switch (_oQuestionBase.QuestionType) { case QuestionTypes.E: lblType.Text = "Essay"; break; case QuestionTypes.MC3: lblType.Text = "Multiple Choice (3 Distractors)"; break; case QuestionTypes.MC4: lblType.Text = "Multiple Choice (4 Distractors)"; break; case QuestionTypes.MC5: lblType.Text = "Multiple Choice (5 Distractors)"; break; case QuestionTypes.S: lblType.Text = "Short Answer"; break; case QuestionTypes.T: lblType.Text = "True/False"; break; default: lblType.Text = "Unknown"; break; } lblScoreType.Text = _oQuestionBase.ScoreType; lblKeywords.Text = _oQuestionBase.Keywords; lblCopyright.Text = String.IsNullOrEmpty(_oQuestionBase.Copyright) ? "No" : _oQuestionBase.Copyright; lblCopyRightExpiryDate.Text = _oQuestionBase.CopyRightExpiryDate == null ? "Not defined" : _oQuestionBase.CopyRightExpiryDate.GetValueOrDefault().Date.ToString("MM/dd/yyyy"); lblSource.Text = _oQuestionBase.Source; lblCredit.Text = _oQuestionBase.Credit; /* Figure out contextually how to display rubric info. If the question's scoretype is not rubric then there is no need to display the "rubric type", "Rubric Scoring" or Rubric Name. * If the question's scoretype is rubric, display rubric type, display rubric scoring, then consider whether it is a "Basic", "holistic", or "analytical" rubric: * If "Basic", then * Also make rubric scoring a hyperlink - when clicked provide pop-up window of rubric's criteria. * don't display rubric name since it is basic (and there isn't any name). * * If "Holistic", then * display rubric name. * Also make rubric name a hyperlink - when clicked provide pop-up window of rubric's criteria. * in popup, provide a link to take user to rubric object page. * * If "Analytical", then * Make rubric scoring a hyperlink - when clicked provide pop-up window of rubric's criteria. * In popup, provide a link to take user to the rubric object page. * Don't display rubric name since it is Analytical. * */ if (_oQuestionBase.ScoreType == "Rubric") { lblRubricType.Text = _oQuestionBase.Rubric.TypeDesc; rowRubricType.Style["display"] = "block"; lblRubricScoring.Text = _oQuestionBase.Rubric.Scoring; rowRubricScoring.Style["display"] = "block"; ItemIDTile_hdnRubricName.Value = _oQuestionBase.Rubric.Name; ItemIDTile_hdnRubricContent.Value = _oQuestionBase.Rubric.Content; switch (_oQuestionBase.Rubric.TypeDesc) { case "Basic": hlRubricScoring.Attributes.Add("onClick", "displayRubricCriteria();"); rowRubricName.Style["display"] = "none"; break; case "Analytical": ItemIDTile_hdnRubricPageUrl.Value = "../../Record/RubricPage.aspx?xID=" + _oQuestionBase.Rubric.ID_Encrypted; hlRubricScoring.Attributes.Add("onClick", "displayRubricCriteria();"); rowRubricName.Style["display"] = "none"; break; case "Holistic": lblRubricName.Text = _oQuestionBase.Rubric.Name; ItemIDTile_hdnRubricPageUrl.Value = "../../Record/RubricPage.aspx?xID=" + _oQuestionBase.Rubric.ID_Encrypted; hlRubricName.Attributes.Add("onClick", "displayRubricCriteria();"); hlRubricScoring.HRef = ""; rowRubricName.Style["display"] = "block"; break; } } }
private void LoadData() { HtmlTableRow oRow; HtmlTableCell oCell; HtmlGenericControl oDiv; if (Tile.TileParms.GetParm("item") == null) return; _questionType = Tile.TileParms.GetParm("item").GetType(); if (_questionType.Name == "BankQuestion") { _oBankQuestion = (BankQuestion)Tile.TileParms.GetParm("item"); _oQuestionBase = (QuestionBase)_oBankQuestion; } else { _oTestQuestion = (TestQuestion)Tile.TileParms.GetParm("item"); _oQuestionBase = (QuestionBase)_oTestQuestion; } /******************************************************************************* * Although for any given version of the Elements application there is only one * type of rigor (either Webb, Marzano, or RBT), and this is determined by the * value of DOK in the Parms table in the database, a bank question may have * all three rigors in its full rigor string. Its just that only one of the * three rigors is used. If displaying a bank question, we intend to display * all the rigors listed in the full rigor string. The full rigor string looks * something like: * Webb=3|RBT=4|Marzano=4| * We get to parse out the different rigors and then use the numeric code of * each and fetch from the database the actual text or description for the code. * * We expect each rigor to be divided by vertical bar '|', and each rigor to be * be of a format: {rigor name}={numeric code} (e.g. RBT=2). * * If displaying a test question, then we will only display the single rigor de- * fined at the district. * *****************************************************************************/ var rgxRigorFormat = new Regex(@"[a-zA-Z]+=\d+"); //this regex pattern should match above format for rigor. /*list of rigors and codes to pass to the database in order to look up code's text*/ dtGeneric_String_Int dtListOfRigors = new dtGeneric_String_Int(); if (_questionType.Name == "BankQuestion") { /*array of strings from full string rigor, each holding a rigor=value pattern, we hope.*/ string[] aRigors = _oQuestionBase.Rigor.FullRigorString.Split('|'); /*loop through array of strings and collect a set of legit rigor/code values in dtListOfRigors*/ foreach (var sRigor in aRigors) { if (rgxRigorFormat.IsMatch(sRigor)) { dtListOfRigors.Add(sRigor.Substring(0, sRigor.IndexOf('=')), DataIntegrity.ConvertToInt(sRigor.Substring(sRigor.IndexOf('=') + 1))); } } /*Pass dtListOfRigors via SP to database in order to look up each rigor's code's text value.*/ var dt = ThinkgateDataAccess.FetchDataTable("E3_RIGOR_GetDescriptionsFromListOfCodes", new object[] { dtListOfRigors.ToSql() }); /* Loop through our result set and build into our tableItemAdvanced html table for displaying */ DataRow drRigor; for (int i = 0; i < dt.Rows.Count; i++) { drRigor = dt.Rows[i]; oRow = new HtmlTableRow(); oCell = new HtmlTableCell(); oCell.Attributes.Add("class", "fieldLabel"); oCell.Attributes.Add("style", "width:130px"); oCell.InnerText = drRigor["Field"].ToString() + ":"; oRow.Cells.Add(oCell); oCell = new HtmlTableCell(); oCell.InnerText = drRigor["Text"].ToString(); oRow.Cells.Add(oCell); tblItemAdvanced.Rows.Insert(i, oRow); } } else { var distParms = DistrictParms.LoadDistrictParms(); oRow = new HtmlTableRow(); oCell = new HtmlTableCell(); oCell.Attributes.Add("class", "fieldLabel"); oCell.Attributes.Add("style", "width:130px"); oCell.InnerText = distParms.DOK; oRow.Cells.Add(oCell); oCell = new HtmlTableCell(); oCell.InnerText = _oQuestionBase.Rigor.ToString(); oRow.Cells.Add(oCell); tblItemAdvanced.Rows.Insert(0, oRow); } lblItemDifficulty.Text = string.Format("{0:#.00##}", _oQuestionBase.ItemDifficulty); lblDifficultyIndex.Text = _oQuestionBase.DifficultyIndex.ToString(); /****************************************************** * The number of Distractor Rationale values vary, so * we need to build the HTML to represent these. * ***************************************************/ foreach (var sDistractorRationale in _oQuestionBase.DistractorRationale) { oDiv = new HtmlGenericControl(); oDiv.InnerHtml = sDistractorRationale; oCell = new HtmlTableCell(); oCell.ColSpan = 2; oCell.Controls.Add(oDiv); oRow = new HtmlTableRow(); oRow.Cells.Add(oCell); tblItemAdvanced.Rows.Add(oRow); } }
internal int GetIndexOf(QuestionBase question) { return this._questions.IndexOf(question); }
internal void RemoveQuestion(QuestionBase question) { _questions.Remove(question); }
private GrpcQuestionBase GetGrpcQuestion(QuestionBase <string> question) { var grpcQuestionsBase = new GrpcQuestionBase() { Key = question.Key ?? "", Order = question.Order, Checked = question.Checked, AfterBox = question.AfterBox, Label = question.Label ?? "", MethodName = question.MethodName ?? "", QuestionsKey = question.QuestionsKey ?? "", Value = question.Value ?? "", ControlType = (GrpcControlType)question.ControlType, Type = (GrpcInputType)question.Type, Validator = GetGrpcQuestionValidator(question.Validator) }; if (question.Options != null) { grpcQuestionsBase.Options.AddRange(question.Options.Select(o => GetGrpcQuestionOption(o))); } if (question.SelectedFrom != null) { if (question.SelectedFrom.GetType() == typeof(int)) { grpcQuestionsBase.SelectedFromInt = (int)question.SelectedFrom; } else if (question.SelectedFrom.GetType() == typeof(double)) { grpcQuestionsBase.SelectedFromDouble = (double)question.SelectedFrom; } else if (question.SelectedFrom.GetType() == typeof(decimal)) { CustomTypes.DecimalValue selectedFrom = (decimal)question.SelectedFrom; grpcQuestionsBase.SelectedFromDecimal = new DecimalValue() { Nanos = selectedFrom.Nanos, Units = selectedFrom.Units }; } } if (question.SelectedTo != null) { if (question.SelectedTo.GetType() == typeof(int)) { grpcQuestionsBase.SelectedToInt = (int)question.SelectedTo; } else if (question.SelectedTo.GetType() == typeof(double)) { grpcQuestionsBase.SelectedToDouble = (double)question.SelectedTo; } else if (question.SelectedTo.GetType() == typeof(decimal)) { CustomTypes.DecimalValue selectedTo = (decimal)question.SelectedTo; grpcQuestionsBase.SelectedToDecimal = new DecimalValue() { Nanos = selectedTo.Nanos, Units = selectedTo.Units }; } } if (question.From != null) { if (question.From.GetType() == typeof(int)) { grpcQuestionsBase.FromInt = (int)question.From; } else if (question.From.GetType() == typeof(double)) { grpcQuestionsBase.FromDouble = (double)question.From; } else if (question.From.GetType() == typeof(decimal)) { CustomTypes.DecimalValue from = (decimal)question.From; grpcQuestionsBase.FromDecimal = new DecimalValue() { Nanos = from.Nanos, Units = from.Units }; } } if (question.To != null) { if (question.To.GetType() == typeof(int)) { grpcQuestionsBase.ToInt = (int)question.To; } else if (question.To.GetType() == typeof(double)) { grpcQuestionsBase.ToDouble = (double)question.To; } else if (question.To.GetType() == typeof(decimal)) { CustomTypes.DecimalValue to = (decimal)question.To; grpcQuestionsBase.ToDecimal = new DecimalValue() { Nanos = to.Nanos, Units = to.Units }; } } return(grpcQuestionsBase); }