public ActionResult CreateCustomer(Customer customer) {
			try {
				var spCtx = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
				using (var ctx = spCtx.CreateUserClientContextForSPHost()) {
					customer.CreateCustomer(ctx);
					return RedirectToAction("Index", new { SPHostUrl = Request.QueryString.Get("SPHostUrl") });
				}
			}
			catch {
				return RedirectToAction("Create");
			}
		}
		public ActionResult EditList(int id, Customer customer) {
			try {
				// TODO: Add update logic here
				var spCtx = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
				using (var ctx = spCtx.CreateUserClientContextForSPHost()) {
					customer.EditCustomer(ctx);
				}
				return RedirectToAction("Index", new { SPHostUrl = Request.QueryString.Get("SPHostUrl") });
			}
			catch (Exception e) {
				ViewBag.e = e;
				throw new HttpException("bad", e);
			}
		}
예제 #3
0
		private static Customer ParseCustomer(this ListItem li) {
			var logo = li["DispLogo"] as FieldUrlValue;

			Customer ret = new Customer();
			ret.ID = int.Parse(li["ID"].ToString());
			//sometimes Title dose not read
			ret.Title = string.IsNullOrEmpty(li["Title"].ToString())? "null" : li["Title"].ToString();
			ret.Logo = logo.Url;
			ret.Address = li["Address"].ToString();
			ret.ContactPerson = li["contactPerson"].ToString();
			ret.OfficePhone = li["phoneOffice"].ToString();
			ret.Mobile = li["phoneMobile"].ToString();
			ret.Email = li["Email"].ToString();
			ret.Created = (DateTime)li["Created"];
			return ret;
		}