Exemple #1
0
    private void SaveAnswers()
    {
        if (this.hidAnswerValues.Value != string.Empty)
        {
            string           jsonResponse     = this.hidAnswerValues.Value;
            JArray           json             = JArray.Parse(jsonResponse);
            SoldatAntwortCol soldatAntwortCol = new SoldatAntwortCol();
            foreach (var item in json)
            {
                JToken frage    = item["FrageID"];
                JToken frageTyp = item["FrageTyp"];
                JToken answer   = item["answer"];

                Guid frageId;
                Guid frageTypId;

                Guid.TryParse(frage.ToString(), out frageId);
                Guid.TryParse(frageTyp.ToString(), out frageTypId);
                if (item["answer"] != null)
                {
                    if (item["answer"] is JArray)
                    {
                        foreach (var antwort in item["answer"])
                        {
                            SoldatAntwort soldatAntwort = new SoldatAntwort();
                            soldatAntwort.Fragen.ID = frageId;
                            Guid antwortId;
                            if (Guid.TryParse(antwort.ToString(), out antwortId))
                            {
                                soldatAntwort.Antwort.AntwortID = antwortId;
                            }
                            else
                            {
                                soldatAntwort.TextAntwort = antwort.ToString();
                            }

                            soldatAntwortCol.Add(soldatAntwort);
                        }
                    }
                    else
                    {
                        SoldatAntwort soldatAntwort = new SoldatAntwort();
                        soldatAntwort.Fragen.ID = frageId;
                        Guid antwortId;
                        if (Guid.TryParse(answer.ToString(), out antwortId))
                        {
                            soldatAntwort.Antwort.AntwortID = antwortId;
                        }
                        else
                        {
                            soldatAntwort.TextAntwort = answer.ToString();
                        }
                        soldatAntwortCol.Add(soldatAntwort);
                    }
                }
            }
            Service.SaveSoldatAntwortCol(soldatAntwortCol, Soldat.ID, Soldat.Anlass.ID);
        }
    }
Exemple #2
0
        public void SaveAntwortCol(SoldatAntwortCol soldatAntwortCol, Guid soldatId, Guid anlassId)
        {
            ParameterCollection parameters = new ParameterCollection();

            parameters.Add(new Parameter("SoldatID", (object)soldatId));
            parameters.Add(new Parameter("AnlassID", (object)anlassId));
            this.Database.SaveCollection((ICollection)soldatAntwortCol, string.Format(this.m_SqlSaveSoldatAntwortCol, (object)soldatId, (object)anlassId), (List <DbParameter>)null, parameters);
        }
Exemple #3
0
 public void SaveSoldatAntwortCol(SoldatAntwortCol soldatAntwortCol, Guid soldatId, Guid anlassId)
 {
     try
     {
         this.m_FrageDao.SaveAntwortCol(soldatAntwortCol, soldatId, anlassId);
     }
     catch (Exception ex)
     {
         throw new Exception("Fehler beim speichern der Antworten", ex);
     }
 }