Beispiel #1
0
 public static void Update(UserPostingQuestionResponse entry, LcDatabase sharedDb = null)
 {
     using (var db = new LcDatabase(sharedDb))
     {
         db.Execute(sqlUpdate, entry.userPostingID, entry.questionID,
                    Newtonsoft.Json.JsonConvert.SerializeObject(entry.responses));
     }
 }
Beispiel #2
0
 public static void Insert(UserPostingQuestionResponse entry, LcDatabase sharedDb = null)
 {
     using (var db = new LcDatabase(sharedDb))
     {
         db.Execute(sqlInsert, entry.userPostingID, entry.questionID, entry.questionTypeID, entry.question,
                    entry.label, entry.helpBlock, entry.legend,
                    Newtonsoft.Json.JsonConvert.SerializeObject(entry.options),
                    Newtonsoft.Json.JsonConvert.SerializeObject(entry.responses),
                    Newtonsoft.Json.JsonConvert.SerializeObject(entry.branchLogic));
     }
 }
Beispiel #3
0
        public static int Set(UserPosting entry, Locale locale, LcDatabase sharedDb = null)
        {
            using (var db = new LcDatabase(sharedDb))
            {
                var neededSpecializationsText  = string.Join(",", entry.neededSpecializationIDs);
                var desiredSpecializationsText = string.Join(",", entry.desiredSpecializationIDs);

                db.Execute("BEGIN TRANSACTION");
                var id = 0;

                if (entry.userPostingID > 0)
                {
                    db.QueryValue(sqlUpdate,
                                  entry.userID,
                                  entry.userPostingID,
                                  entry.title,
                                  neededSpecializationsText,
                                  desiredSpecializationsText
                                  );
                    id = entry.userPostingID;
                    foreach (var qr in entry.questionsResponses)
                    {
                        qr.userPostingID = id;
                        UserPostingQuestionResponse.Update(qr, db);
                    }
                }
                else
                {
                    id = (int)db.QueryValue(sqlInsert,
                                            entry.userID,
                                            entry.solutionID,
                                            entry.postingTemplateID,
                                            entry.statusID,
                                            entry.title,
                                            neededSpecializationsText,
                                            desiredSpecializationsText,
                                            locale.languageID,
                                            locale.countryID,
                                            entry.userID
                                            );
                    foreach (var qr in entry.questionsResponses)
                    {
                        qr.userPostingID = id;
                        UserPostingQuestionResponse.Insert(qr, db);
                    }
                }

                db.Execute("COMMIT TRANSACTION");
                return(id);
            }
        }
Beispiel #4
0
 public void FillQuestionsResponses()
 {
     questionsResponses = UserPostingQuestionResponse.List(userPostingID);
 }