public ActionResult Create(string country, string spHostUrl) { var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); using (var clientContext = spContext.CreateUserClientContextForSPAppWeb()) { var service = new PartSuppliersService(clientContext); var id = service.GetIdByCountry(country); if (id == null) { id = service.Add(country); TempData["Message"] = "Part Supplier Successfully Created!"; } else TempData["ErrorMessage"] = string.Format("Failed to Create The Part Supplier: There's already a Part Supplier who's country is {0}.", country); return RedirectToAction("Details", new { id = id.Value, SPHostUrl = spHostUrl }); } }