Beispiel #1
0
        public ActionResult Index(SurveyViewModel model)
        {
            try
            {
                Entry entry = new Entry();
                entry.SurveyID = model.SurveyId;
                if (User.Identity.Name != "")
                {
                    entry.UserID = User.Identity.Name;
                }
                entry.Date = DateTime.Now;

                int entryid = _repository.CreateEntry(entry);

                foreach (var question in model.Questions)
                {
                    Response r = new Response();
                    r.Date = DateTime.Now;
                    r.Question = question.QuestionId;
                    r.Answer = question.SelectedAnswer;
                    r.Survey = model.SurveyId;
                    r.UserID = User.Identity.Name;
                    r.Entry = entryid;
                    _repository.CreateResponse(r);
                }
            }
            catch (Exception e)
            {
                TempData["Message"] = e;
                return View("Error");
            }

            TempData["Message"] = "Good times.";
            return View("Thanks");
        }
Beispiel #2
0
 public int CreateEntry(Entry entry)
 {
     try
     {
         _context.AddToEntries(entry);
         _context.SaveChanges();
         return entry.ID;
     }
     catch (Exception)
     {
         return 0;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Create a new Entry object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="surveyID">Initial value of the SurveyID property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 public static Entry CreateEntry(global::System.Int32 id, global::System.Int32 surveyID, global::System.DateTime date)
 {
     Entry entry = new Entry();
     entry.ID = id;
     entry.SurveyID = surveyID;
     entry.Date = date;
     return entry;
 }
Beispiel #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Entries EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEntries(Entry entry)
 {
     base.AddObject("Entries", entry);
 }