public void When_sending_a_rejection_email() { var email = S<IEmailService>(); var organizer = new User("organizer") { Email = "*****@*****.**" }; var callForSpeakers = new CallForSpeakers { Organizer = organizer, EventName = "event" }; var speaker = new User("foo") { Email = "*****@*****.**" }; var submission = new Submission(speaker, new SubmissionViewModel {Title = "title"}, callForSpeakers) { RejectionReason = "rejection reason" }; var sender = new DomainEmailSender(email); sender.SubmissionRejection(submission); emailMessage = (EmailMessage) email.GetArgumentsForCallsMadeOn(x => x.Send(null))[0][0]; }
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 void Should_map_from_entity() { var user = new User("foo"); var entity = new CallForSpeakers { Description = "description", EventName = "event name", FirstDayOfEvent = new DateTime(2001,1,2), Id = 123, LastDayOfEvent = new DateTime(2001,1,3), LastDayToSubmit = new DateTime(2001,1,4), LogoUrl = "logo url", Slug = "asdasd", Organizer = user }; var input = new CallForSpeakersInput(entity); input.Description.ShouldEqual(entity.Description); input.EventName.ShouldEqual(entity.EventName); input.FirstDayOfEvent.ShouldEqual(entity.FirstDayOfEvent); input.Id.ShouldEqual(entity.Id); input.LastDayOfEvent.ShouldEqual(entity.LastDayOfEvent); input.LastDayToSubmit.ShouldEqual(entity.LastDayToSubmit); input.LogoUrl.ShouldEqual(entity.LogoUrl); }
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 SubmissionViewModel(User speaker, CallForSpeakers callForSpeakers) { CallForSpeakers = callForSpeakers; CallForSpeakersId = callForSpeakers.Id; SpeakerName = speaker.Name; SpeakerEmail = speaker.Email; SpeakerTwitter = speaker.Twitter; SpeakerImageUrl = speaker.ImageUrl; }
public SpeakerProfile(CreateSpeakerProfileInput input, User user) { Maintainer = user; Name = input.Name; Email = input.Email; Twitter = input.Twitter; PhoneNumber = input.PhoneNumber; Bio = input.Bio; ImageUrl = input.ImageUrl; HomePageUrl = input.HomePageUrl; }
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, User user) { if (ModelState.IsValid) { using (var db = new DataContext(user)) { db.CallsForSpeakers.Add(new CallForSpeakers(input, user)); db.SaveChanges(); } return RedirectToAction("Index", "Home"); } return View(); }
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 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 Submission(User submitter, SubmissionViewModel input, CallForSpeakers callForSpeakers) { Submitter = submitter; CallForSpeakers = callForSpeakers; Title = input.Title; Abstract = input.Abstract; Status = Submitted; SpeakerName = input.SpeakerName; SpeakerBio = input.SpeakerBio; SpeakerEmail = input.SpeakerEmail; SpeakerPhone = input.SpeakerPhone; SpeakerTwitter = input.SpeakerTwitter; SpeakerImageUrl = input.SpeakerImageUrl; }
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); } }
public void Should_map_from_entity() { var entity = new User("foo") { Email = "email", Id = 2, Twitter = "twitter", ImageUrl = "image url", Name = "name" }; var input = new UserDetailsInput(entity); input.EmailAddress.ShouldEqual(entity.Email); input.Name.ShouldEqual(entity.Name); input.Twitter.ShouldEqual(entity.Twitter); }
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 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"); }
public ViewResult Details(User user) { return View(new UserDetailsInput(user)); }
public ActionResult Review(User user, long id) { return RenderReview(user, id); }
public CallForSpeakers(CallForSpeakersInput input, User user) : this(input) { Organizer = user; }
public ActionResult Reject(User user, RejectionInput input) { return PerformTransition(user, input, x => x.Reject(input.Reason, _email), "You have successfully rejected this submission"); }
// TODO: need to investigate context per request or something public DataContext(User modelBoundUser) { Entry(modelBoundUser).State = EntityState.Unchanged; }
public UserDetailsInput(User user) { Name = user.Name; EmailAddress = user.Email; Twitter = user.Twitter; }
public PartialViewResult Pbar(User user) { var model = new PbarModel { LoginLink = Url.Action("Login", new{returnUrl = HttpContext.Request.Url.AbsoluteUri}), LogoutLink = Url.Action("Logout"), AccountDetailsLink = Url.Action("Details") }; if (user != null) { model.IsAuthenticated = true; model.UsersName = user.Name; model.PictureUrl = user.ImageUrl; } return PartialView(model); }
public ActionResult Accept(User user, DecisionInput input) { return PerformTransition(user, input, x => x.Accept(_email), "You have successfully accepted this submission."); }