ActionResult PerformTransition(User user, DecisionInput input, Action<Submission> action, string successText) { if (ModelState.IsValid) { using (var db = new DataContext(user)) { var submission = db.Submissions.Include(x => x.CallForSpeakers) .Include(x => x.Submitter) .SingleOrDefault(x => x.Id == input.Id && x.CallForSpeakers.Id == input.CallForSpeakersId && x.CallForSpeakers.Organizer.Id == user.Id); if (submission != null) { action(submission); db.SaveChanges(); Success(successText); } else { Error("Invalid submission"); } return RedirectToAction("Review", new { id = input.CallForSpeakersId }); } } return RenderReview(user, input.CallForSpeakersId); }
public LoginStatus ProcessLogin(string token) { var authInfo = _engageClient.GetAuthInfo(token); if (authInfo == null || !authInfo.IsOk()) return LoginStatus.Failed(); var identifier = authInfo.profile.identifier; using (var db = new DataContext()) { User foundUser = db.Users.SingleOrDefault(x => identifier == x.Identifier); if (foundUser != null) { return LoginStatus.ReturnVisit(identifier); } var newUser = new User(identifier) { Email = authInfo.profile.verifiedEmail ?? authInfo.profile.email, Name = authInfo.profile.displayName, ImageUrl = authInfo.profile.photo }; db.Users.Add(newUser); db.SaveChanges(); return LoginStatus.FirstVisit(identifier); } }
public ActionResult ProcessLogin(string token, string returnUrl) { if (string.IsNullOrWhiteSpace(token)) { return Login(returnUrl); } try { var client = new RestClient("https://rpxnow.com/"); var request = new RestRequest("api/v2/auth_info"); request.AddParameter("token", token); request.AddParameter("apiKey", ConfigurationManager.AppSettings["janrainApiKey"]); // ಠ_ಠ // client.Proxy = new WebProxy("127.0.0.1", 5865); // client.Proxy = new WebProxy("10.210.54.120", 5865); // client.Proxy = new WebProxy(new Uri("http://proxy:80"), false, null, CredentialCache.DefaultNetworkCredentials); IRestResponse<AuthInfo> response = client.Execute<AuthInfo>(request); if (response != null && response.Data != null && response.Data.IsOk() && response.Data.profile != null) { using (var db = new DataContext()) { User foundUser = db.Users.Find(response.Data.profile.identifier); if (foundUser == null) { var newUser = new User(response.Data.profile.identifier) { Email = response.Data.profile.verifiedEmail ?? response.Data.profile.email, Name = response.Data.profile.displayName, ImageUrl = response.Data.profile.photo }; db.Users.Add(newUser); db.SaveChanges(); } } FormsAuthentication.SetAuthCookie(response.Data.profile.identifier, false); } else { return RedirectToAction("Login"); } } catch { return RedirectToAction("Login"); } string url = Url.IsLocalUrl(returnUrl) ? returnUrl : "~/organizer/home"; return Redirect(url); }
public ActionResult ProcessCreation(CallForSpeakersInput input) { if (ModelState.IsValid) { using (var db = new DataContext()) { db.CallsForSpeakers.Add(new CallForSpeakers(input)); db.SaveChanges(); } return RedirectToAction("Index", "Home"); } return View(); }
public ActionResult ProcessCreation(CreateSpeakerProfileInput input, User user) { if (ModelState.IsValid) { using (var db = new DataContext(user)) { db.SpeakerProfiles.Add(new SpeakerProfile(input, user)); db.SaveChanges(); } return RedirectToAction("Index", "Home", new {area = "Organizer"}); } return View(); }
public ActionResult ProcessDetails(UserDetailsInput input, User user) { if (ModelState.IsValid) { using (var db = new DataContext(user)) { user.Name = input.Name; user.Email = input.EmailAddress; user.Twitter = input.Twitter; db.SaveChanges(); } return RedirectToAction("Index", "Home", new { area = "organizer" }); } return View("Details"); }
public ActionResult ProcessSubmission(User user, SubmissionViewModel input) { if (ModelState.IsValid) { using (var db = new DataContext(user)) { var found = db.CallsForSpeakers.Find(input.CallForSpeakersId); if (found == null) { Error("There was a problem submitting this session"); return RedirectToAction("Index", "Home", new {area = ""}); } var submission = new Submission(user, input, found); db.Submissions.Add(submission); db.SaveChanges(); } Success("Successfully submitted session"); return RedirectToAction("Index", "Home", new { area = "" }); } return View("Create"); }