コード例 #1
0
        public ActionResult Create()
        {
            var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
              // get the current host url
              ViewBag.SPHostUrl = spContext.SPHostUrl;

              // create viewmodel & return
              var model = new CreateCustomerViewModel();
              return View(model);
        }
コード例 #2
0
        public ActionResult Create(CreateCustomerViewModel viewModel)
        {
            if (ModelState.IsValid) {
            var customer = new Customer();
            customer.FirstName = viewModel.FirstName;
            customer.LastName = viewModel.LastName;
            customer.Email = viewModel.Email;

            _db.Customers.Add(customer);
            _db.SaveChanges();

            return RedirectToAction("Index", "Home", new { SPHostUrl = SharePointContext.GetSPHostUrl(HttpContext.Request).AbsoluteUri });
              }
              return View(viewModel);
        }