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); } }
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 object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { string userIdentifier = controllerContext.HttpContext.User.Identity.Name; using (var db = new DataContext()) { return db.Users.AsNoTracking().SingleOrDefault(x => x.Identifier == userIdentifier); } }
public ViewResult Index() { var model = new HomeViewModel(); using (var db = new DataContext()) { model.CallForSpeakersCount = db.CallsForSpeakers.Count(); return View(model); } }
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 ViewResult Index(User user) { using (var db = new DataContext(user)) { var calls = db.CallsForSpeakers.AsNoTracking().Where(x => x.Organizer.Id == user.Id); var speakers = db.SpeakerProfiles.AsNoTracking().Where(x => x.Maintainer.Id == user.Id); var model = new HomeViewModel(calls, speakers); return View(model); } }
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 Call(string key) { using (var db = new DataContext()) { var found = db.CallsForSpeakers.AsNoTracking().SingleOrDefault(x => x.Slug.ToLower() == key.ToLower()); if (found == null) { TempData["error"] = "The call for speakers cannot be found"; return RedirectToAction("Index"); } return View(found); } }
public ActionResult Submission(User speaker, long id) { using (var db = new DataContext(speaker)) { var sub = db.Submissions.Include("CallForSpeakers").SingleOrDefault(x => x.Id == id && x.Submitter.Id == speaker.Id); if (sub == null) { Error("Invalid submission"); return RedirectToAction("Index", "MySubmissions"); } return View(sub); } }
public ActionResult Create(User user, string slug) { using (var db = new DataContext(user)) { var found = db.CallsForSpeakers.SingleOrDefault(x => x.Slug == slug); if (found == null) { Error("Invalid call for speakers"); return RedirectToAction("Index", "Home"); } return View(new SubmissionViewModel(user, found)); } }
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 ViewResult Index(User speaker) { using (var db = new DataContext(speaker)) { var all = db.Submissions .Include("CallForSpeakers") .AsNoTracking() .Where(x => x.Submitter.Id == speaker.Id) .OrderBy(x => x.CallForSpeakers.LastDayToSubmit) .ThenBy(x => x.CallForSpeakers.EventName) .ThenBy(x => x.Title) .ToArray(); return View("Index", all); } }
ActionResult RenderReview(User user, long id) { using (var db = new DataContext(user)) { var submissions = db.Submissions.Include(x => x.CallForSpeakers) .Include(x => x.Submitter) .Where(x => x.CallForSpeakers.Id == id && x.CallForSpeakers.Organizer.Id == user.Id); if (!submissions.Any()) { Error("No submissions"); return RedirectToAction("Index", "Home"); } return View("Review", submissions.ToArray()); } }
public EventPlanningModel Get(int id) { var result = new EventPlanningModel(); using (var db = new DataContext()) { var conf = db.CallsForSpeakers.Include(x => x.Organizer) .SingleOrDefault(x => x.Id == id); if (conf == null) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)); } result.EventName = conf.EventName; result.EventDescription = conf.Description; result.EventLogoUrl = conf.LogoUrl; result.OrganizerName = conf.Organizer.Name; result.OrganizerEmail = conf.Organizer.Email; result.FirstDay = conf.FirstDayOfEvent; result.LastDay = conf.LastDayOfEvent; result.LastDayToSubmit = conf.LastDayToSubmit; var acceptedSessions = db.Submissions .Where(s => s.CallForSpeakers.Id == id && s.Status == Submission.Accepted).ToArray(); result.AcceptedSubmissions = acceptedSessions.Select(x => new AcceptedSubmissions { Abstract = x.Abstract, Title = x.Title, SpeakerEmail = x.SpeakerEmail, SpeakerName = x.SpeakerName, SpeakerPhotoUrl = x.SpeakerImageUrl, SpeakerTwitter = x.SpeakerTwitter, SpeakerBio = x.SpeakerBio, SpeakerPhone = x.SpeakerPhone }); } return result; }
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"); }