示例#1
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();
            }
        }