Пример #1
0
 /// <summary>
 /// Create a new Survey object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 public static Survey CreateSurvey(global::System.Int32 id, global::System.String title, global::System.DateTime date)
 {
     Survey survey = new Survey();
     survey.Id = id;
     survey.Title = title;
     survey.Date = date;
     return survey;
 }
Пример #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Survey EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSurvey(Survey survey)
 {
     base.AddObject("Survey", survey);
 }
Пример #3
0
        public ActionResult Create(FormCollection form, int customerId)
        {
            try
            {
                using (var context = new LibraryContainer())
                {
                    var customer = context.Customer.First(c => c.Id == customerId);

                    var survey = new Survey
                                     {
                                         Date = DateTime.Now,
                                         Title = form["Title"],
                                         Description = HttpUtility.HtmlDecode(form["Description"]),
                                         Customer = customer
                                     };

                    context.AddToSurvey(survey);
                    context.SaveChanges();

                    return RedirectToAction("Index");
                }
            }
            catch
            {
                return View();
            }
        }