Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Newly created with PayPal integration

  • Loading branch information...
commit 005ef954fd7a8ac8c87d19f6932d532b425f1a33 1 parent ba96510
@rasesh rasesh authored
Showing with 2,408 additions and 0 deletions.
  1. +63 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Account/Login.cshtml
  2. +4 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Account/Logout.cshtml
  3. +96 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Account/Register.cshtml
  4. +18 −0 OrlandoCodeCamp/PhotoSharing-PayPal/App_Code/EnumerableExtensions.cs
  5. +729 −0 OrlandoCodeCamp/PhotoSharing-PayPal/App_Code/Facebook.cshtml
  6. +146 −0 OrlandoCodeCamp/PhotoSharing-PayPal/App_Code/MultiThumbnailGenerator.cs
  7. +13 −0 OrlandoCodeCamp/PhotoSharing-PayPal/App_Code/PhotoGallery.cshtml
  8. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/App_Data/PhotoGallery.sdf
  9. BIN  ...ndoCodeCamp/PhotoSharing-PayPal/App_Data/packages/microsoft-web-helpers.1.0/microsoft-web-helpers.1.0.nupkg
  10. +4 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Default.cshtml
  11. +31 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/Default.cshtml
  12. +42 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/New.cshtml
  13. +35 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/Thumbnail.cshtml
  14. +49 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/Upload.cshtml
  15. +41 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/View.cshtml
  16. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/download.png
  17. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/gallery-empty.png
  18. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/header-bkg.png
  19. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/icon-account.png
  20. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/icon-gallery.png
  21. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/icon-tags.png
  22. +58 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/Edit.cshtml
  23. +68 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/EditTags.cshtml
  24. +15 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/Full.cshtml
  25. +51 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/OrderSuccess.cshtml
  26. +45 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/Remove.cshtml
  27. +38 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/Thumbnail.cshtml
  28. +146 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/View.cshtml
  29. +456 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Styles/Site.css
  30. +30 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Tag/Default.cshtml
  31. +33 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Tag/Thumbnail.cshtml
  32. +45 −0 OrlandoCodeCamp/PhotoSharing-PayPal/Tag/View.cshtml
  33. +48 −0 OrlandoCodeCamp/PhotoSharing-PayPal/User/Default.cshtml
  34. +53 −0 OrlandoCodeCamp/PhotoSharing-PayPal/User/View.cshtml
  35. +12 −0 OrlandoCodeCamp/PhotoSharing-PayPal/_AppStart.cshtml
  36. +4 −0 OrlandoCodeCamp/PhotoSharing-PayPal/_PageStart.cshtml
  37. +33 −0 OrlandoCodeCamp/PhotoSharing-PayPal/_SiteLayout.cshtml
  38. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/bin/Microsoft.Web.Helpers.dll
  39. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/bin/PayPal.dll
  40. BIN  OrlandoCodeCamp/PhotoSharing-PayPal/favicon.ico
  41. +2 −0  OrlandoCodeCamp/PhotoSharing-PayPal/robots.txt
View
63 OrlandoCodeCamp/PhotoSharing-PayPal/Account/Login.cshtml
@@ -0,0 +1,63 @@
+@{
+ Page.Title = "Login";
+
+ if (IsPost) {
+ var email = Request["email"];
+ if (email.IsEmpty()) {
+ ModelState.AddError("email", "You must specify an email address.");
+ }
+
+ var password = Request["password"];
+ if (password.IsEmpty()) {
+ ModelState.AddError("password", "You must specify a password.");
+ }
+
+ if (ModelState.IsValid) {
+ var rememberMe = Request["rememberMe"].AsBool();
+ if (WebSecurity.Login(email, password, rememberMe)) {
+ string returnUrl = Request["returnUrl"];
+ if (!returnUrl.IsEmpty()) {
+ Context.RedirectLocal(returnUrl);
+ } else{
+ Response.Redirect("~/");
+ }
+ } else {
+ ModelState.AddFormError("The email or password provided is incorrect.");
+ }
+ }
+ }
+}
+
+<h1>Login</h1>
+
+<p>
+ Please enter your email and password below. If you don't have an account,
+ please <a href="@Href("Register")">Register</a>.
+</p>
+
+@Html.ValidationSummary(excludeFieldErrors: true)
+
+<form method="post" action="">
+ <fieldset class="no-legend">
+ <legend>Login</legend>
+ <ol>
+ <li class="email">
+ <label for="email">Email</label>
+ <input type="text" id="email" name="email" title="Email Address" placeholder="Email address" class="@PhotoGallery.GetValidationClass("email")" />
+ @Html.ValidationMessage("email")
+ </li>
+ <li class="Password">
+ <label for="password">Password</label>
+ <input type="password" id="password" name="password" title="Password" class="@PhotoGallery.GetValidationClass("password")" />
+ @Html.ValidationMessage("password")
+ </li>
+ <li class="remember-me">
+ <label class="checkbox" for="rememberMe">Remember Me?</label>
+ <input type="checkbox" id="rememberMe" name="rememberMe" value="true" title="Remember Me" />
+ </li>
+ </ol>
+ <p class="form-actions">
+ <input type="submit" value="Login" title="Login" />
+ </p>
+ </fieldset>
+</form>
View
4 OrlandoCodeCamp/PhotoSharing-PayPal/Account/Logout.cshtml
@@ -0,0 +1,4 @@
+@{
+ WebSecurity.Logout();
+ Response.Redirect("~/");
+}
View
96 OrlandoCodeCamp/PhotoSharing-PayPal/Account/Register.cshtml
@@ -0,0 +1,96 @@
+@{
+ Page.Title = "Register";
+
+ if (IsPost) {
+ //if (!ReCaptcha.Validate("PRIVATE_KEY")) {
+ // ModelState.AddFormError("Captcha response was not correct.");
+ //}
+
+ var email = Request["email"];
+ if (email.IsEmpty()) {
+ ModelState.AddError("email", "You must specify an email address.");
+ }
+
+ var password = Request["password"];
+ var confirmPassword = Request["confirmPassword"];
+
+ if (password.IsEmpty()) {
+ ModelState.AddError("password", "You must specify a password.");
+ }
+
+ if (confirmPassword.IsEmpty()) {
+ ModelState.AddError("confirmPassword", "You must specify a confirm password.");
+ }
+
+ if (password != confirmPassword) {
+ ModelState.AddFormError("The new password and confirmation password do not match.");
+ }
+
+ if (ModelState.IsValid) {
+ // Create the user profile
+ var db = Database.Open("PhotoGallery");
+
+ // Check if user already exists
+ var user = db.QuerySingle("SELECT Email FROM UserProfiles WHERE LOWER(Email) = LOWER(@0)", email);
+ if (user == null) {
+ // Insert email into the profile table
+ db.Execute("INSERT INTO UserProfiles (Email, DisplayName, Bio) VALUES (@0, @1, @2)", email, email, "");
+
+ // Create and associate a new entry in the membership database.
+ // If successful, continue processing the request
+ try {
+ WebSecurity.CreateAccount(email, password);
+ WebSecurity.Login(email, password);
+ Response.Redirect("~/");
+ } catch (System.Web.Security.MembershipCreateUserException e) {
+ ModelState.AddFormError(e.ToString());
+ }
+ } else {
+ // User already exists
+ ModelState.AddFormError("Email address is already in use.");
+ }
+ }
+ }
+}
+
+<h1>Account Creation</h1>
+<p>
+ Use the form below to create a new account.
+</p>
+
+@Html.ValidationSummary(excludeFieldErrors: true)
+
+<form method="post" action="">
+ <fieldset class="no-legend">
+ <legend>Account Creation</legend>
+ <ol>
+ <li class="email">
+ <label for="email">Email:</label>
+ <input type="text" id="email" name="email" title="Email address" placeholder="Email address" class="@PhotoGallery.GetValidationClass("email")" />
+ @Html.ValidationMessage("email")
+ </li>
+ <li class="password">
+ <label for="password">Password:</label>
+ <input type="password" id="password" name="password" title="Password" class="@PhotoGallery.GetValidationClass("password")" />
+ @Html.ValidationMessage("password")
+ </li>
+ <li class="confirm-password">
+ <label for="confirmPassword">Confirm Password:</label>
+ <input type="password" id="confirmPassword" name="confirmPassword" title="Confirm password" class="@PhotoGallery.GetValidationClass("confirmPassword")" />
+ @Html.ValidationMessage("confirmPassword")
+ </li>
+ <li class="recaptcha">
+ <div class="message info">
+ <p>To enable CAPTCHA verification, uncomment ReCaptcha.GetHtml and replace 'PUBLIC_KEY'
+ with your public key. At the top of this page, uncomment ReCaptcha.Validate and
+ replace 'PRIVATE_KEY' with your private key.</p>
+ <p>Register for reCAPTCHA keys at <a href="http://recaptcha.net">reCAPTCHA.net</a>.</p>
+ </div>
+ @*@ReCaptcha.GetHtml("PUBLIC_KEY", theme: "white")*@
+ </li>
+ </ol>
+ <p class="form-actions">
+ <input type="submit" value="Register" title="Register" />
+ </p>
+ </fieldset>
+</form>
View
18 OrlandoCodeCamp/PhotoSharing-PayPal/App_Code/EnumerableExtensions.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+public static class EnumerableExtensions {
+
+ public static IEnumerable<TSource> Shuffle<TSource>(this IEnumerable<TSource> source) {
+ List<TSource> list = source.ToList();
+ Random random = new Random();
+
+ for (int i = list.Count - 1; i >= 0; i--) {
+ int r = random.Next(i + 1);
+ yield return list[r];
+ list[r] = list[i];
+ }
+ }
+
+}
View
729 OrlandoCodeCamp/PhotoSharing-PayPal/App_Code/Facebook.cshtml
@@ -0,0 +1,729 @@
+@using System.Collections.Specialized;
+@using System.Security;
+@using System.Text;
+@using System.Web.WebPages.Scope;
+
+@functions {
+
+ private const string FacebookCredentialsTableName = "webpages_FacebookCredentials";
+ private const string FacebookCredentialsIdColumn = "FacebookId";
+ private const string FacebookCredentialsUserIdColumn = "UserId";
+
+ private const string DefaultUserIdColumn = "UserId";
+ private const string DefaultUserNameColumn = "email";
+ private const string DefaultUserTableName = "UserProfile";
+
+ private const string DefaultFacebookPerms = "email";
+ private const string DefaultCallbackUrl = "~/Facebook/Login";
+ private const string FacebookApiProfileUrl = "https://graph.facebook.com/me";
+
+ private static readonly object _isInitializedKey = new object();
+ private static readonly object _membershipDBNameKey = new object();
+ private static readonly object _appIdKey = new object();
+ private static readonly object _appSecretKey = new object();
+ private static readonly object _language = new object();
+
+ public static bool HasMembershipIntegration {
+ get {
+ return !MembershipDBName.IsEmpty();
+ }
+ }
+
+ public static bool IsFacebookUserAuthenticated {
+ get {
+ return !GetFacebookCookieInfo("uid").IsEmpty();
+ }
+ }
+
+ public static bool IsFacebookUserAssociated {
+ get {
+ return !GetAssociatedMembershipUserName().IsEmpty();
+ }
+ }
+
+ public static bool IsInitialized {
+ get {
+ return (bool) (ScopeStorage.CurrentScope[_isInitializedKey] ?? false);
+ }
+
+ private set {
+ ScopeStorage.CurrentScope[_isInitializedKey] = value;
+ }
+ }
+
+ public static string MembershipDBName {
+ get {
+ return (string) (ScopeStorage.CurrentScope[_membershipDBNameKey] ?? "");
+ }
+
+ set {
+ ScopeStorage.CurrentScope[_membershipDBNameKey] = value;
+ }
+ }
+
+ public static string AppId {
+ get {
+ return (string) (ScopeStorage.CurrentScope[_appIdKey] ?? "");
+ }
+
+ set {
+ ScopeStorage.CurrentScope[_appIdKey] = value;
+ }
+ }
+
+ public static string AppSecret {
+ get {
+ return (string) (ScopeStorage.CurrentScope[_appSecretKey] ?? "");
+ }
+
+ set {
+ ScopeStorage.CurrentScope[_appSecretKey] = value;
+ }
+ }
+
+ public static string Language {
+ get {
+ return (string) (ScopeStorage.CurrentScope[_language] ?? "en_US");
+ }
+
+ set {
+ ScopeStorage.CurrentScope[_language] = value;
+ }
+ }
+
+ ///<summary>
+ /// Initialize the helper with your Facebook application settings.
+ ///
+ /// If the 'membershipDBName' parameter is specified, Facebook membership integration will be enabled,
+ /// allowing users to register and associate their Facebook user account (identified with the e-mail)
+ /// with your site membership and the WebSecurity helper.
+ /// In this case, the helper will initialize the WebSecurity WebMatrix helper automatically (if not done previously)
+ /// and the store the Facebook membership information in the 'membershipDbName' database.
+ ///</summary>
+ ///<param name="appId">Facebook application id.</param>
+ ///<param name="appSecret">Facebook application secret.</param>
+ ///<param name="membershipDBName">Name of the database used for storing the membership data.</param>
+ public static void Initialize(string appId, string appSecret, string membershipDbName = "") {
+ AppId = appId;
+ AppSecret = appSecret;
+ IsInitialized = true;
+
+ if (!membershipDbName.IsEmpty()) {
+ MembershipDBName = membershipDbName;
+
+ InitializeMembershipProviderIfNeeded();
+ InitializeFacebookTableIfNeeded();
+ }
+ }
+
+ ///<summary>
+ /// Retrieves the Facebook profile of current logged in user.
+ ///</summary>
+ public static UserProfile GetFacebookUserProfile() {
+ var accessToken = GetFacebookCookieInfo("access_token");
+
+ if (accessToken.IsEmpty()) {
+ return null;
+ }
+
+ var userProfileUrl = new Uri(string.Format("{0}?access_token={1}", FacebookApiProfileUrl, accessToken));
+
+ var receiveStream = new WebClient().OpenRead(userProfileUrl);
+ var result = new StreamReader(receiveStream).ReadToEnd();
+ var profile = Json.Decode<UserProfile>(result);
+
+ return profile;
+ }
+
+ ///<summary>
+ /// Associates the specified User Name (e.g. email, depending on your membership model) with the current Facebook User Id from the logged user.
+ ///</summary>
+ ///<param name="userId">The user name to associate the current logged-in facebook account to.</param>
+ public static void AssociateMembershipAccount(string userName) {
+ if (!IsFacebookUserAuthenticated) {
+ throw new InvalidOperationException("No Facebook user is authenticated.");
+ }
+
+ if (IsFacebookUserAssociated) {
+ throw new InvalidOperationException("The authenticated Facebook user is already associated to a membership account.");
+ }
+
+ using (Database db = Database.Open(MembershipDBName)) {
+ var facebookUserId = GetFacebookCookieInfo("uid").As<long>();
+
+ var userId = WebSecurity.GetUserId(userName);
+ db.Execute(string.Format("INSERT INTO {0} ({1}, {2}) VALUES (@0, @1)", FacebookCredentialsTableName, FacebookCredentialsUserIdColumn, FacebookCredentialsIdColumn), userId, facebookUserId);
+
+ // User is registered in the application
+ FormsAuthentication.SetAuthCookie(userName, false);
+ }
+ }
+
+ public static bool MembershipLogin() {
+ var user = GetAssociatedMembershipUserName();
+
+ if (!user.IsEmpty()) {
+ // User is registered in the application
+ FormsAuthentication.SetAuthCookie(user, false);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private static void InitializeMembershipProviderIfNeeded() {
+ var provider = GetMembershipProvider();
+
+ if (IsMembershipProviderInitialized(provider)) {
+ WebSecurity.InitializeDatabaseConnection(MembershipDBName, DefaultUserTableName, DefaultUserIdColumn, DefaultUserNameColumn, true);
+ }
+ }
+
+ private static void InitializeFacebookTableIfNeeded() {
+ var provider = GetMembershipProvider();
+ var db = Database.Open(MembershipDBName);
+ var table = db.QuerySingle("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @0", FacebookCredentialsTableName);
+
+ if (table == null) {
+ db.Execute(string.Format("CREATE TABLE {0} ({1} INT NOT NULL, {2} BIGINT NOT NULL)", FacebookCredentialsTableName, FacebookCredentialsUserIdColumn, FacebookCredentialsIdColumn));
+ }
+ }
+
+ private static string GetAssociatedMembershipUserName() {
+ var userName = "";
+
+ if (IsFacebookUserAuthenticated) {
+ var db = Database.Open(MembershipDBName);
+ var provider = GetMembershipProvider();
+
+ var userId = db.QueryValue(string.Format("SELECT {0} FROM {1} WHERE {2} = LOWER(@0)", FacebookCredentialsUserIdColumn, FacebookCredentialsTableName, FacebookCredentialsIdColumn), GetFacebookCookieInfo("uid"));
+ if (userId != null) {
+ userName = GetUserName(userId);
+ }
+ }
+
+ return userName;
+ }
+
+ private static string GetUserName(int userId) {
+ var userName = "";
+
+ var db = Database.Open(MembershipDBName);
+ var provider = GetMembershipProvider();
+ userName = db.QueryValue(string.Format("SELECT {0} FROM {1} WHERE {2} = @0", provider.UserNameColumn, provider.UserTableName, provider.UserIdColumn), userId);
+
+ return userName;
+ }
+
+ private static SimpleMembershipProvider GetMembershipProvider() {
+ var provider = Membership.Provider as SimpleMembershipProvider;
+
+ if (provider == null) {
+ throw new InvalidOperationException("Simple Membership Provider not found.");
+ }
+
+ return provider;
+ }
+
+ private static bool IsMembershipProviderInitialized(SimpleMembershipProvider provider) {
+ return provider.UserTableName.IsEmpty() || provider.UserIdColumn.IsEmpty() || provider.UserNameColumn.IsEmpty();
+ }
+
+ private static string GetFacebookCookieInfo(string key) {
+ var request = HttpContext.Current.Request;
+ var name = string.Format("fbs_{0}", AppId);
+
+ if (request.Cookies[name] != null) {
+ var value = request.Cookies[name].Value;
+ var args = HttpUtility.ParseQueryString(value.Replace("\"", ""));
+
+ if (!IsFacebookCookieValid(args)) {
+ throw new SecurityException("Invalid Facebook cookie.");
+ }
+
+ return args[key];
+ } else {
+ return "";
+ }
+ }
+
+ private static bool IsFacebookCookieValid(NameValueCollection args) {
+ var payload = new StringBuilder();
+ foreach (var key in args.AllKeys) {
+ if (key != "sig") {
+ payload.AppendFormat("{0}={1}", key, args[key]);
+ }
+ }
+
+ payload.Append(AppSecret);
+
+ var md5 = System.Security.Cryptography.MD5CryptoServiceProvider.Create();
+ var hash = md5.ComputeHash(Encoding.ASCII.GetBytes(payload.ToString()));
+ var signature = new StringBuilder();
+ for (int i = 0; i < hash.Length; i++) {
+ signature.Append(hash[i].ToString("X2"));
+ }
+
+ return string.Equals(args["sig"], signature.ToString(), StringComparison.InvariantCultureIgnoreCase);
+ }
+
+ public class UserProfile {
+ public string Id { get; set; }
+ public string Name { get; set; }
+ public string First_Name { get; set; }
+ public string Last_Name { get; set; }
+ public string Link { get; set; }
+ public string Bio { get; set; }
+ public string Gender { get; set; }
+ public string Email { get; set; }
+ public string Timezone { get; set; }
+ public string Locale { get; set; }
+ public string Updated_Time { get; set; }
+ }
+}
+
+@*
+Summary:
+ Initialize the Facebook JavaScript SDK to be able to support the XFBML tags of the social plugins.
+*@
+@helper GetInitializationScripts() {
+ <div id="fb-root"></div>
+ <script type="text/javascript">
+ window.fbAsyncInit = function() {
+ FB.init({appId: '@AppId', status: true, cookie: true, xfbml: true});
+ };
+ (function() {
+ var e = document.createElement('script'); e.async = true;
+ e.src = document.location.protocol +
+ '//connect.facebook.net/@(Language)/all.js';
+ document.getElementById('fb-root').appendChild(e);
+ }());
+
+ function loginRedirect(url) { window.location = url; }
+ </script>
+}
+
+@*
+Summary:
+ Shows a Facebook Login Button, with site membership integration, allowing users to login on your site with their Facebook account (e-mail).
+ To use this method, you need to provide the 'membershipDbName' in the helper's Initialize() method.
+
+Parameter: registerUrl
+ Specifies the URL to register the logged user, and associate it with a Membership account.
+Parameter: returnUrl
+ Specifies URL to redirect after the user has successfully logged in (i.e. the Facebook User has a Membership Account).
+Parameter: callbackUrl
+ Specifies the URL of the WebMatrix page that will handle the Membership login (default URL is ~/Facebook/Login.cshtml).
+Parameter: buttonText
+ Specifies the Login Button Text.
+Parameter: autoLogoutLink
+ When set to true, if the user is logged into Facebook the button will display a logout button instead.
+Parameter: size
+ Specifies the button size: "small", "medium", "large", "xlarge".
+Paramter: length
+ Specifies the text lenght: "long" --> 'Connect with Facebook" or "short" --> 'Connect'.
+Parameter: showFaces
+ Specifies whether to display profile photos below the button.
+Parameter: extendedPermissions
+ The extendedPermissions parameter can be used to request extended permissions from the user. For example, if you want to incorporate a user's photos into your application, set this value to “user_photos”.
+*@
+@helper LoginButton(
+ string registerUrl,
+ string returnUrl = "~/",
+ string callbackUrl = DefaultCallbackUrl,
+ string buttonText = "",
+ bool autoLogoutLink = false,
+ string size = "medium",
+ string length = "long",
+ bool showFaces = false,
+ string extendedPermissions = "") {
+
+ var redirectUrl = Href(string.Format("{0}?registerUrl={1}&returnUrl={2}", callbackUrl, HttpUtility.UrlEncode(registerUrl), HttpUtility.UrlEncode(returnUrl)));
+ var onLogin = string.Format("loginRedirect('{0}')", redirectUrl);
+ extendedPermissions = extendedPermissions.IsEmpty() ? "email" : string.Concat("email,", extendedPermissions);
+
+ <fb:login-button autologoutlink="@autoLogoutLink" size="@size" length="@length" onlogin="@onLogin" show-faces="@showFaces" perms="@extendedPermissions">@buttonText</fb:login-button>
+}
+
+@*
+Summary:
+ Shows a Facebook Login Button, without integrating Facebook login with your site membership.
+
+Parameter: buttonText
+ Specifies the Login Button Text.
+Parameter: autoLogoutLink
+ When set to true, if the user is logged into Facebook the button will display a logout button instead.
+Parameter: size
+ The button size: "small", "medium", "large", "xlarge".
+Parameter: length
+ The text lenght: "long" --> 'Connect with Facebook" or "short" --> 'Connect'
+Parameter: onLogin
+ Specifies the JavaScript action to execute after the user login.
+Parameter: showFaces
+ Whether to display profile photos below the button.
+Parameter: extendedPermissions
+ The extendedPermissions parameter can be used to request extended permissions from the user. For example, if you want to incorporate a user's photos into your application, set this value to “user_photos”.
+*@
+@helper LoginButtonTagOnly(
+ string buttonText = "",
+ bool autoLogoutLink = false,
+ string size = "long",
+ string length = "short",
+ string onLogin = "",
+ bool showFaces = false,
+ string extendedPermissions = "") {
+ <fb:login-button autologoutlink="@autoLogoutLink" size="@size" length="@length" onlogin="@onLogin" show-faces="@showFaces" perms="@extendedPermissions">@buttonText</fb:login-button>
+}
+
+@*
+Summary:
+ Shows a Facebook Like Button. When the user clicks the Like button on your site, a story appears in the user's friends' News Feed with a link back to your website.
+
+Parameter: href
+ The URL to like.
+Parameter: buttonLayout
+ The button layout:
+ - standard: Displays social text to the right of the button and friends' profile photos below.
+ Minimum width: 225 pixels. Default width: 450 pixels. Height: 35 pixels (without photos) or 80 pixels (with photos).
+ - button_count: Displays the total number of likes to the right of the button.
+ Minimum width: 90 pixels. Default width: 90 pixels. Height: 20 pixels.
+Parameter: showFaces
+ Specifies whether to display profile photos below the button (standard layout only).
+Parameter: width
+ The width of the Like button.
+Parameter: height
+ The height of the plugin in pixels.
+Parameter: action
+ The verb to display on the button: 'like', 'recommend'.
+Parameter: font
+ The font to display in the button: 'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'.
+Parameter: colorScheme
+ The color scheme for the like button: 'light' or 'dark'.
+Parameter: refLabel
+ A label for tracking referrals; must be less than 50 characters and can contain alphanumeric characters and some punctuation (currently +/=-.:_).
+
+*@
+@helper LikeButton(
+ string href = "",
+ string buttonLayout = "standard",
+ bool showFaces = true,
+ int width = 450,
+ int height = 80,
+ string action = "like",
+ string font = "",
+ string colorScheme = "light",
+ string refLabel = ""
+ ) {
+ if (href.IsEmpty()) {
+ href = Request.Url.ToString();
+ }
+
+ <iframe src="http://www.facebook.com/plugins/like.php?href=@href&layout=@buttonLayout&show_faces=@showFaces&width=@width&action=@action&colorscheme=@colorScheme&height=@height&font=@font&locale=@Language&ref=@refLabel" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:@(width)px; height:@(height)px;" allowTransparency="true"></iframe>
+}
+
+@*
+Summary:
+ Shows a Facebook Comments plugin.
+ The Comments Box easily enables your users to comment on your site's content — whether it's for a web page, article, photo, or other piece of content.
+ Then the user can share the comment on Facebook on their Wall and in their friends' streams.
+ An 'Administer Comments' link will appear below the 'Post' button for developers of the application.
+
+Parameter: xid
+ An id associated with the comments object (defaults to URL-encoded page URL).
+Parameter: width
+ The width of the plugin, in pixels.
+Parameter: numPosts
+ The number of comments to display, or 0 to hide all comments.
+Parameter: reverse
+ Changes the order of comments and comment area to allow greater customization.
+Parameter: removeRoundedBox
+ Removes the rounded box around the text area where comments are written to allow greater customization.
+*@
+@helper Comments(
+ string xid = "",
+ int width = 550,
+ int numPosts = 10,
+ bool reverseOrder = false,
+ bool removeRoundedBox = false) {
+ <fb:comments @if (!xid.IsEmpty()) { <text>xid="@xid"</text> }numposts="@numPosts" width="@width" reverse="@reverseOrder" simple="@removeRoundedBox" ></fb:comments>
+}
+
+@*
+Summary:
+ Shows a Facebook Recommendations plugin. The Recommendations plugin shows personalized recommendations to your users.
+ Since the content is hosted by Facebook, the plugin can display personalized recommendations whether or not the user has logged into your site.
+ To generate the recommendations, the plugin considers all the social interactions with URLs from your site.
+ For a logged in Facebook user, the plugin will give preference to and highlight objects her friends have interacted with.
+
+ *NOTE*: This helper method requires that your site is published into a public address where others can use it. Check this tutorial on publishing with WebMatrix: http://www.asp.net/webmatrix/tutorials/publish-a-website
+
+Parameter: site
+ The address of your published site. For example "www.fourthcoffee.com"
+Parameter: width
+ The width of the plugin in pixels.
+Parameter: height
+ The height of the plugin in pixels.
+Parameter: showHeader
+ Whether to show a 'Recommendations' title bar.
+Parameter: colorScheme
+ The color scheme of the plugin: 'light' or 'dark'.
+Parameter: font
+ The font name for the plugin.
+Parameter: borderColor
+ The border color of the plugin. Use common color names as Red, White, Black, and so on.
+Parameter: filter
+ Allows you to filter which URLs are shown in the plugin. The plugin will only include URLs which contain the filter term in the first two path parameters of the URL.
+Parameter: refLabel
+ A label for tracking referrals; must be less than 50 characters and can contain alphanumeric characters and some punctuation (currently +/=-.:_).
+*@
+@helper Recommendations(
+ string site = "",
+ int width = 300,
+ int height = 300,
+ bool showHeader = true,
+ string colorScheme = "light",
+ string font = "",
+ string borderColor = "",
+ string filter = "",
+ string refLabel = ""
+ ) {
+ if (site.IsEmpty()) {
+ site = Request.Url.Host;
+ }
+
+ <iframe src="http://www.facebook.com/plugins/recommendations.php?site=@site&width=@width&height=@height&header=@showHeader&colorscheme=@colorScheme&font=@font&border_color=@borderColor&filter=@filter&ref=@refLabel&locale=@Language" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:@(width)px; height:@(height)px;" allowTransparency="true"></iframe>
+}
+
+@*
+Summary:
+ Shows a Facebook Like Box. The Like Box is a social plugin that enables Facebook Page owners to attract and gain Likes from their own website.
+ The Like Box enables users to:
+ - See how many users already like this page, and which of their friends like it too
+ - Read recent posts from the page
+ - Like the page with one click, without needing to visit the page
+
+Parameter: href
+ The URL of the Facebook Page for this Like box.
+Parameter: width
+ The width of the plugin in pixels.
+Parameter: height
+ The height of the plugin in pixels.
+Parameter: colorScheme
+ The color scheme of the plugin: 'light' or 'dark'.
+Parameter: connections
+ Number of shown users who have liked this Page. Use 0 to avoid showing the users box.
+Parameter: showStream
+ Shows the profile stream for the public profile of the page.
+Parameter: showHeader
+ Shows the 'Find us on Facebook' bar at top. Only shown when either stream or connections are present.
+*@
+@helper LikeBox(
+ string href,
+ int width = 292,
+ int height = 587,
+ string colorScheme = "light",
+ int connections = 10,
+ bool showStream = true,
+ bool showHeader = true) {
+ <iframe src="http://www.facebook.com/plugins/likebox.php?href=@href&width=@width&height=@height&colorscheme=@colorScheme&connections=@connections&stream=@showStream&header=@showHeader&locale=@Language" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:@(width)px; height:@(height)px;" allowTransparency="true"></iframe>
+}
+
+@*
+Summary:
+ Shows a Facebook Facepile plugin.
+ The Facepile plugin shows the Facebook profile pictures of the user's friends who have already signed up for your site.
+ The plugin doesn't show up if the user is logged out of Facebook or doesn't have friends who have signed up for your site using Facebook.
+
+Parameter: maxRows
+ The maximum number of rows of profile pictures to show. The plugin dynamically sizes its height; for example, if you specify a maximum of four rows, and there are only enough friends to fill two rows, the height of the plugin will be only what is needed for two rows of profile pictures.
+Parameter: width
+ The width of the plugin in pixels.
+*@
+@helper Facepile(
+ int maxRows = 1,
+ int width = 200) {
+ <fb:facepile max-rows="@maxRows" width="@width"></fb:facepile>
+}
+
+@*
+Summary:
+ Shows a Facebook Live Stream plugin.
+ The Live Stream plugin lets users visiting your site or application share activity and comments in real time.
+ The Live Stream Box works best when you are running a real-time event, like live streaming video for concerts, speeches, or webcasts, live Web chats,
+ webinars, massively multiplayer games.
+
+Parameter: width
+ The width of the plugin in pixels.
+Parameter: height
+ The height of the plugin in pixels.
+Parameter: xid
+ If you have multiple live stream boxes on the same page, specify a unique 'xid' for each.
+Parameter: viaUrl
+ The URL that users are redirected to when they click on your app name on a status (if not specified, your Connect URL is used).
+Parameter: alwaysPostToFriends
+ If set, all user posts will always go to their profile. This option should only be used when users' posts are likely to make sense outside of the context of the event.
+*@
+@helper LiveStream(
+ int width = 400,
+ int height = 500,
+ string xid = "",
+ string viaUrl = "",
+ bool allwaysPostToFriends = false ) {
+ <iframe src="http://www.facebook.com/plugins/live_stream_box.php?app_id=@AppId&width=@width&height=@height@if (!xid.IsEmpty()) { <text>&xid=@xid</text> }@if (!xid.IsEmpty()) { <text>&via_url=@viaUrl</text> }&always_post_to_friends=@allwaysPostToFriends&locale=@Language" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:@(width)px; height:@(height)px;" allowTransparency="true"></iframe>
+}
+
+@*
+Summary:
+ Shows a Facebook Activity Feed plugin.
+ The Activity Feed plugin displays the most interesting recent activity taking place on your site. Since the content is hosted by Facebook,
+ the plugin can display personalized content whether or not the user has logged into your site. The activity feed displays stories both when
+ users like content on your site and when users share content from your site back to Facebook.
+
+ *NOTE*: This helper method requires that your site is published into a public address where others can use it. Check this tutorial on publishing with WebMatrix: http://www.asp.net/webmatrix/tutorials/publish-a-website
+
+Parameter: site
+ The address of your published site. For example "www.fourthcoffee.com"
+Parameter: width
+ The width of the plugin in pixels.
+Parameter: height
+ The height of the plugin in pixels.
+Parameter: showHeader
+ Show the 'Recent Activity' title bar.
+Parameter: colorScheme
+ The color scheme of the plugin: 'light' or 'dark'.
+Parameter: font
+ The font name for the plugin.
+Parameter: borderColor
+ The border color of the plugin. Use common color names as Red, White, Black, and so on.
+Parameter: showRecommendations
+ Whether to show recommendations on the activity feed.
+*@
+@helper ActivityFeed(
+ string site = "",
+ int width = 300,
+ int height = 300,
+ bool showHeader = true,
+ string colorScheme = "light",
+ string font = "",
+ string borderColor = "",
+ bool showRecommendations = false) {
+ if (site.IsEmpty()) {
+ site = Request.Url.Host;
+ }
+
+ <iframe src="http://www.facebook.com/plugins/activity.php?site=@site&width=@width&height=@height&header=@showHeader&colorscheme=@colorScheme&font=@font&border_color=@borderColor&recommendations=@showRecommendations&locale=@Language" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:300px;" allowTransparency="true"></iframe>
+}
+
+@*
+Summary:
+ OpenGraph properties allows you to specify structured information about your web pages to show up your pages richly across Facebook and enable Facebook users to establish connections to your pages.
+
+ Use this method to show OpenGraph page data, as the page title, URL, and so on.
+
+ *NOTE*: It is important to notice that the OpenGraph properties are read directly from your site by Facebook, therefore your site needs to be published into a public address to see the OpenGraph properties working.
+ Check this tutorial on publishing with WebMatrix: http://www.asp.net/webmatrix/tutorials/publish-a-website
+
+Parameter: siteName
+ A human-readable name for your site, e.g., "Fourth Coffee".
+Parameter: title
+ The title of your page as it should appear within Facebook, e.g., "Pecan Pie".
+Parameter: type
+ The type of your page, e.g., "food". See the complete list of supported types here: http://developers.facebook.com/docs/opengraph#types
+Parameter: url
+ The canonical URL of your object that will be used as its permanent ID in the graph, e.g., http://www.fourthcoffe.com/Product/1/.
+Parameter: imageUrl
+ An image URL which should represent your page within the graph. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1.
+Parameter: description
+ A one to two sentence description of your page.
+*@
+@helper OpenGraphRequiredProperties(
+ string siteName,
+ string title,
+ string type,
+ string url,
+ string imageUrl,
+ string description = "") {
+ <meta property="og:site_name" content="@siteName"/>
+ <meta property="fb:app_id" content="@AppId"/>
+ <meta property="og:title" content="@title"/>
+ <meta property="og:type" content="@type"/>
+ <meta property="og:url" content="@url"/>
+ <meta property="og:image" content="@imageUrl"/>
+ if (!description.IsEmpty()) {
+ <meta property="og:description" content="@description"/>
+ }
+}
+
+@*
+Summary:
+ OpenGraph properties allows you to specify structured information about your web pages to show up your pages richly across Facebook and enable Facebook users to establish connections to your pages.
+
+ Use this method to show page location data. This is useful if your pages is a business profile or about anything else with a real-world location. You can specify location via latitude and longitude, a full address, or both.
+
+ *NOTE*: It is important to notice that the OpenGraph properties are read directly from your site by Facebook, therefore your site needs to be published into a public address to see the OpenGraph properties working.
+ Check this tutorial on publishing with WebMatrix: http://www.asp.net/webmatrix/tutorials/publish-a-website
+*@
+@helper OpenGraphLocationProperties(
+ string latitude = "",
+ string longitude = "",
+ string streetAddress = "",
+ string locality = "",
+ string region = "",
+ string postalCode = "",
+ string countryName = "") {
+ if (!latitude.IsEmpty()) {
+ <meta property="og:latitude" content="@latitude"/>
+ }
+ if (!longitude.IsEmpty()) {
+ <meta property="og:longitude" content="@longitude"/>
+ }
+ if (!streetAddress.IsEmpty()) {
+ <meta property="og:street-address" content="@streetAddress"/>
+ }
+ if (!locality.IsEmpty()) {
+ <meta property="og:locality" content="@locality"/>
+ }
+ if (!region.IsEmpty()) {
+ <meta property="og:region" content="@region"/>
+ }
+ if (!postalCode.IsEmpty()) {
+ <meta property="og:postal-code" content="@postalCode"/>
+ }
+ if (!countryName.IsEmpty()) {
+ <meta property="og:country-name" content="@countryName"/>
+ }
+}
+
+@*
+Summary:
+ OpenGraph properties allows you to specify structured information about your web pages to show up your pages richly across Facebook and enable Facebook users to establish connections to your pages.
+
+ Use this method to show contact information about your page. Consider including contact information if your page is about an entity that can be contacted.
+
+ *NOTE*: It is important to notice that the OpenGraph properties are read directly from your site by Facebook, therefore your site needs to be published into a public address to see the OpenGraph properties working.
+ Check this tutorial on publishing with WebMatrix: http://www.asp.net/webmatrix/tutorials/publish-a-website
+*@
+@helper OpenGraphContactProperties(
+ string email = "",
+ string phoneNumber = "",
+ string faxNumber = "") {
+
+ if (!email.IsEmpty()) {
+ <meta property="og:email" content="@email"/>
+ }
+ if (!phoneNumber.IsEmpty()) {
+ <meta property="og:phone_number" content="@phoneNumber"/>
+ }
+ if (!faxNumber.IsEmpty()) {
+ <meta property="og:fax_number" content="@faxNumber"/>
+ }
+
+}
+
+@*
+Summary:
+ Use this method inside your opening HTML tag for W3C compatibility.
+ For example: <html xmlns="http://www.w3.org/1999/xhtml" @Facebook.FbmlNamespaces()>
+*@
+@helper FbmlNamespaces() {
+ <text>xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"</text> }
View
146 OrlandoCodeCamp/PhotoSharing-PayPal/App_Code/MultiThumbnailGenerator.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.IO;
+
+public class MultiThumbnailGenerator : IDisposable {
+ /* common variables */
+ private static int imageDimension = 200;
+ private static float maxMultiplier = 0.7f;
+ private static float maxDimension = (float)imageDimension * maxMultiplier;
+ private static float thinLineWidth = 0.6f;
+ private static float thickLineWidth = 2.0f;
+ private static float maxAngle = 25f;
+
+ /* instance variables */
+ private Random random = new Random();
+ private Bitmap surfaceBitmap = new Bitmap(imageDimension, imageDimension);
+ private Graphics surfaceGraphics;
+ private RectangleF? surfaceBounds;
+
+ public MultiThumbnailGenerator() {
+ surfaceGraphics = Graphics.FromImage(surfaceBitmap);
+ surfaceGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
+ surfaceGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ }
+
+ public void AddImage(Image image) {
+ // scale image
+ float widthMultiplier = maxDimension / (float)image.Width;
+ float heightMultiplier = maxDimension / (float)image.Height;
+ float minMultiplier = Math.Min(Math.Min(widthMultiplier, heightMultiplier), 1f);
+ float newWidth = minMultiplier * (float)image.Width;
+ float newHeight = minMultiplier * (float)image.Height;
+
+ // choose a random translation & rotation
+ float angle = GetRandomAngle();
+ PointF newDimensions = RotateAndFindNewDimensions(new PointF(newWidth, newHeight), angle);
+ PointF offset = GetRandomOffset(newDimensions);
+ surfaceGraphics.TranslateTransform(offset.X, offset.Y);
+ surfaceGraphics.RotateTransform(angle);
+
+ // draw borders + image
+ DrawRectangle(Brushes.White, newWidth, newHeight, thickLineWidth);
+ DrawRectangle(Brushes.Black, newWidth, newHeight, thinLineWidth);
+ surfaceGraphics.DrawImage(image, -newWidth / 2f, -newHeight / 2f, newWidth, newHeight);
+
+ // calculate new image boundaries
+ RectangleF newBounds = new RectangleF(
+ offset.X - newDimensions.X / 2f,
+ offset.Y - newDimensions.Y / 2f,
+ newDimensions.X,
+ newDimensions.Y);
+
+ if (surfaceBounds.HasValue) {
+ surfaceBounds = Union(surfaceBounds.Value, newBounds);
+ } else {
+ surfaceBounds = newBounds;
+ }
+
+ surfaceGraphics.ResetTransform();
+ }
+
+ private void DrawRectangle(Brush brush, float width, float height, float lineWidth) {
+ surfaceGraphics.FillRectangle(brush,
+ -width / 2f - lineWidth,
+ -height / 2f - lineWidth,
+ width + 2f * lineWidth,
+ height + 2f * lineWidth);
+ }
+
+ private static PointF RotateAndFindNewDimensions(PointF point, float angle) {
+ using (Matrix matrix = new Matrix()) {
+ PointF[] points = new PointF[] {
+ new PointF(0f, 0f),
+ new PointF(0f, point.Y),
+ new PointF(point.X, 0f),
+ new PointF(point.X, point.Y)
+ };
+
+ matrix.Rotate(angle);
+ matrix.TransformPoints(points);
+ float minX = points[0].X;
+ float maxX = minX;
+ float minY = points[0].Y;
+ float maxY = minY;
+ for (int i = 1; i < 4; i++) {
+ minX = Math.Min(minX, points[i].X);
+ maxX = Math.Max(maxX, points[i].X);
+ minY = Math.Min(minY, points[i].Y);
+ maxY = Math.Max(maxY, points[i].Y);
+ }
+
+ return new PointF(maxX - minX, maxY - minY);
+ }
+ }
+
+ private static RectangleF Union(RectangleF oldBounds, RectangleF newBounds) {
+ float left = Math.Min(oldBounds.Left, newBounds.Left);
+ float top = Math.Min(oldBounds.Top, newBounds.Top);
+ float right = Math.Max(oldBounds.Right, newBounds.Right);
+ float bottom = Math.Max(oldBounds.Bottom, newBounds.Bottom);
+ return new RectangleF(left, top, right - left, bottom - top);
+ }
+
+ private float GetRandomAngle() {
+ float r = (float)random.NextDouble();
+ return (r * 2f - 1f) * maxAngle;
+ }
+
+ private PointF GetRandomOffset(PointF dimensions) {
+ float deltaX = (float)imageDimension - dimensions.X - 2f * (thinLineWidth + 1f);
+ float deltaY = (float)imageDimension - dimensions.Y - 2f * (thinLineWidth + 1f);
+
+ float rX = (float)random.NextDouble();
+ float rY = (float)random.NextDouble();
+
+ float newX = (deltaX * rX) + (dimensions.X / 2f) + thinLineWidth + 1f;
+ float newY = (deltaY * rY) + (dimensions.Y / 2f) + thinLineWidth + 1f;
+
+ return new PointF(newX, newY);
+ }
+
+ public void Dispose() {
+ surfaceGraphics.Dispose();
+ surfaceBitmap.Dispose();
+ }
+
+ public void WritePngToStream(Stream outStream) {
+ using (Bitmap outBitmap = new Bitmap(imageDimension, imageDimension)) {
+ using (Graphics outGraphics = Graphics.FromImage(outBitmap)) {
+
+ outGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
+ outGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+
+ // center the image
+ RectangleF bounds = surfaceBounds ?? new RectangleF();
+ float deltaX = (imageDimension - bounds.Width) / 2f - bounds.Left;
+ float deltaY = (imageDimension - bounds.Height) / 2f - bounds.Top;
+ outGraphics.DrawImage(surfaceBitmap, new PointF(deltaX, deltaY));
+
+ outBitmap.Save(outStream, System.Drawing.Imaging.ImageFormat.Png);
+ }
+ }
+ }
+
+}
View
13 OrlandoCodeCamp/PhotoSharing-PayPal/App_Code/PhotoGallery.cshtml
@@ -0,0 +1,13 @@
+@helper GetValidationClass(string fieldName) {
+ var p = CurrentPage as WebPage;
+ if (p == null) {
+ return;
+ }
+
+ var className = "input-validation-valid";
+ var modelState = p.ModelState[fieldName];
+ if (modelState != null && modelState.Errors.Count != 0) {
+ className = "input-validation-error";
+ }
+ @className
+}
View
BIN  OrlandoCodeCamp/PhotoSharing-PayPal/App_Data/PhotoGallery.sdf
Binary file not shown
View
BIN  ...haring-PayPal/App_Data/packages/microsoft-web-helpers.1.0/microsoft-web-helpers.1.0.nupkg
Binary file not shown
View
4 OrlandoCodeCamp/PhotoSharing-PayPal/Default.cshtml
@@ -0,0 +1,4 @@
+@{
+ // Redirect to the start page that we want
+ Response.Redirect("~/Gallery");
+}
View
31 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/Default.cshtml
@@ -0,0 +1,31 @@
+@{
+ Page.Title = "Photo Gallery";
+
+ var db = Database.Open("PhotoGallery");
+ var galleries = db.Query(@"SELECT Galleries.Id, Galleries.Name, COUNT(Photos.Id) AS PhotoCount
+ FROM Galleries LEFT OUTER JOIN Photos ON Galleries.Id = Photos.GalleryId
+ GROUP BY Galleries.Id, Galleries.Name").ToList();
+}
+
+<h1>Galleries</h1>
+@if (galleries.Count == 1) {
+ <p>There is one gallery.</p>
+} else {
+ <p>There are @galleries.Count galleries.</p>
+}
+<ul class="thumbnails gallery">
+ @foreach (var gallery in galleries) {
+ <li class="gallery">
+ <a href="@Href("~/Gallery/View", gallery.Id)">
+ <img alt="Images from @gallery.Name" src="@Href("~/Gallery/Thumbnail", gallery.Id)" class="thumbnail-no-border" />
+ <span class="below-image">@gallery.Name</span>
+ <span class="image-overlay">@gallery.PhotoCount photo(s)</span>
+ </a>
+ </li>
+ }
+</ul>
+<p class="actions">
+@if (WebSecurity.IsAuthenticated) {
+ <a href="@Href("~/Gallery/New")">Create a New Gallery</a>
+}
+</p>
View
42 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/New.cshtml
@@ -0,0 +1,42 @@
+@{
+ WebSecurity.RequireAuthenticatedUser();
+
+ Page.Title = "New Gallery";
+
+ if (IsPost) {
+ var galleryName = Request["Name"];
+ if (galleryName.IsEmpty()) {
+ ModelState.AddError("Name", "You must specify a gallery name.");
+ }
+ if (ModelState.IsValid) {
+ var db = Database.Open("PhotoGallery");
+ var nameExists = db.QueryValue("SELECT COUNT(*) FROM Galleries WHERE LOWER(Name) = LOWER(@0)", galleryName) > 0;
+ if (nameExists) {
+ ModelState.AddError("Name", "A gallery with the supplied name already exists.");
+ } else {
+ //Create Gallery
+ db.Execute("INSERT INTO Galleries (Name) VALUES (@0)", galleryName);
+ // And redirect
+ Response.Redirect(Href("View", db.GetLastInsertId()));
+ }
+ }
+ }
+}
+
+<h1>New Gallery</h1>
+<form method="post" action="">
+ <fieldset>
+ <legend>New Gallery</legend>
+ <ol>
+ <li>
+ <label for="name">Name</label>
+ <input type="text" id="name" name="name" title="Gallery name" placeholder="Gallery name" class="@PhotoGallery.GetValidationClass("name")" />
+ @Html.ValidationMessage("Name")
+ </li>
+ </ol>
+ <p class="form-actions">
+ <input type="submit" value="Create" title="Create gallery" />
+ <a href="@Href("~/Gallery")" title="Return to galleries">Cancel</a>
+ </p>
+ </fieldset>
+</form>
View
35 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/Thumbnail.cshtml
@@ -0,0 +1,35 @@
+@{
+ // Cache the image for a minute
+ Response.OutputCache(60);
+
+ var galleryId = UrlData[0].AsInt();
+
+ var db = Database.Open("PhotoGallery");
+
+ var gallery = db.QuerySingle("SELECT * FROM Galleries WHERE Id = @0", galleryId);
+ if (gallery == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ var photos = db.Query("SELECT TOP(3) FileContents, UploadDate FROM Photos WHERE GalleryId = @0 ORDER BY UploadDate DESC", galleryId);
+ if (photos.Count() == 0) {
+ Response.Redirect("~/Images/gallery-empty.png");
+ return;
+ }
+
+ using (var generator = new MultiThumbnailGenerator()) {
+ foreach (var photo in photos) {
+ using (var imageStream = new System.IO.MemoryStream(photo.FileContents)) {
+ using (var image = System.Drawing.Image.FromStream(imageStream)) {
+ generator.AddImage(image);
+ }
+ }
+ }
+ using (var outStream = new System.IO.MemoryStream()) {
+ generator.WritePngToStream(outStream);
+ var image = new WebImage(outStream);
+ image.Write();
+ }
+ }
+}
View
49 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/Upload.cshtml
@@ -0,0 +1,49 @@
+@{
+ WebSecurity.RequireAuthenticatedUser();
+
+ var galleryId = UrlData[0].AsInt();
+
+ var db = Database.Open("PhotoGallery");
+
+ var gallery = db.QuerySingle("SELECT * FROM Galleries WHERE Id = @0", galleryId);
+ if (gallery == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ Page.Title = "Upload Photo to Gallery - " + gallery.Name;
+ if (IsPost) {
+ var numFiles = Request.Files.Count;
+ for (int i = 0; i < numFiles; i++) {
+ var file = Request.Files[i];
+ if (file.ContentLength > 0) {
+ var fileUpload = new WebImage(file.InputStream);
+ var fileTitle = Path.GetFileNameWithoutExtension(file.FileName).Trim();
+ if (fileTitle.IsEmpty()) {
+ fileTitle = "Untitled";
+ }
+ var fileExtension = Path.GetExtension(file.FileName).Trim();
+ var fileBytes = fileUpload.GetBytes();
+ db.Execute(@"INSERT INTO Photos
+ (GalleryId, UserId, Description, FileTitle, FileExtension, ContentType, FileSize, UploadDate, FileContents) VALUES
+ (@0, @1, @2, @3, @4, @5, @6, @7, @8)", galleryId, WebSecurity.CurrentUserId, "", fileTitle, fileExtension,
+ fileUpload.ImageFormat, fileBytes.Length, DateTime.Now, fileBytes);
+ }
+ }
+ Response.Redirect(Href("~/Photo/View", db.GetLastInsertId()));
+ }
+}
+
+<h1>Upload Photo</h1>
+
+<p>
+ The photo you upload will be placed in the
+ <a class="italic" href="@Href("View", galleryId)">@gallery.Name</a> gallery.
+</p>
+
+@FileUpload.GetHtml()
+
+
+<div class="message info">
+ The default file size is limited to 4MB. To change this you will need to update the 'HttpRuntimeSection/MaxRequestLength' section in web.config.
+</div>
View
41 OrlandoCodeCamp/PhotoSharing-PayPal/Gallery/View.cshtml
@@ -0,0 +1,41 @@
+@{
+ var galleryId = UrlData[0].AsInt();
+
+ var db = Database.Open("PhotoGallery");
+
+ var gallery = db.QuerySingle("SELECT * FROM Galleries WHERE Id = @0", galleryId);
+ if (gallery == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ // Found a match - so show all its photos
+ var photos = db.Query("SELECT Id, FileTitle FROM Photos WHERE GalleryId = @0", galleryId).ToList();
+
+ Page.Title = "Gallery - " + gallery.Name;
+}
+
+<h1>@gallery.Name</h1>
+
+@if (photos.Count == 1) {
+ <p>This gallery contains one photo.</p>
+} else {
+ <p>This gallery contains @photos.Count photos.</p>
+}
+
+<ul class="thumbnails">
+ @foreach (var photo in photos) {
+ <li>
+ <a href="@Href("~/Photo/View", photo.Id)">
+ <img alt="thumbnail of @Path.GetFileNameWithoutExtension(photo.FileTitle)" src="@Href("~/Photo/Thumbnail", photo.Id)" class="thumbnail-border" />
+ <span class="image-overlay">@Path.GetFileNameWithoutExtension(photo.FileTitle)</span>
+ </a>
+ </li>
+ }
+</ul>
+
+@if (WebSecurity.IsAuthenticated) {
+ <p class="actions">
+ <a href="@Href("~/Gallery/Upload", galleryId)">Upload a Photo</a>
+ </p>
+}
View
BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/download.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/gallery-empty.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/header-bkg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/icon-account.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/icon-gallery.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  OrlandoCodeCamp/PhotoSharing-PayPal/Images/icon-tags.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
58 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/Edit.cshtml
@@ -0,0 +1,58 @@
+@{
+ var photoId = UrlData[0].AsInt();
+
+ var db = Database.Open("PhotoGallery");
+
+ var photo = db.QuerySingle("SELECT * FROM Photos WHERE Id = @0", photoId);
+ if (photo == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ WebSecurity.RequireUser(photo.UserId);
+
+ Page.Title = "Edit Photo - " + photo.FileTitle;
+
+ if (IsPost) {
+ var fileTitle = Request["FileTitle"];
+ if (fileTitle.IsEmpty()) {
+ ModelState.AddError("FileTitle", "You must specify a name");
+ }
+ var description = Request["Description"];
+ if (description.IsEmpty()) {
+ ModelState.AddError("Description", "You must specify a description");
+ }
+ if (ModelState.IsValid) {
+ db.Execute("UPDATE Photos SET FileTitle = @0, Description= @1 WHERE Id = @2", fileTitle, description, photoId);
+ Response.Redirect(Href("View", photo.Id));
+ }
+ }
+}
+
+<div class="sidebar">
+ <h1>Edit Photo</h1>
+ <form method="post" action="">
+ <fieldset class="no-legend">
+ <legend>Edit Photo</legend>
+ <ol>
+ <li>
+ <label for="fileTitle">Name:</label>
+ <input type="text" id="fileTitle" name="fileTitle" title="Photo name" value="@photo.FileTitle" placeholder="Photo Name" class="@PhotoGallery.GetValidationClass("fileTitle")" />
+ @Html.ValidationMessage("FileTitle")
+ </li>
+ <li>
+ <label for="description">Description:</label>
+ <textarea id="description" name="description" title="Photo description" rows="4" cols="30" placeholder="Photo description" class="@PhotoGallery.GetValidationClass("description")">@photo.Description</textarea>
+ @Html.ValidationMessage("Description")
+ </li>
+ </ol>
+ <p class="form-actions">
+ <input type="submit" value="Save Changes" title="Save changes" />
+ <a href="@Href("~/Photo/View", photoId)" title="Cancel changes">Cancel</a>
+ </p>
+ </fieldset>
+ </form>
+</div>
+<div class="main">
+ <img alt="@Html.AttributeEncode(photo.FileTitle)" src="@Href("~/Photo/Thumbnail", photo.Id, new { size="large" })" />
+</div>
View
68 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/EditTags.cshtml
@@ -0,0 +1,68 @@
+@{
+ WebSecurity.RequireAuthenticatedUser();
+
+ var photoId = UrlData[0].AsInt();
+
+ var db = Database.Open("PhotoGallery");
+
+ var photo = db.QuerySingle("SELECT * FROM Photos WHERE Id = @0", photoId);
+ if (photo == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ Page.Title = "Photo Tags - " + photo.FileTitle;
+
+ if (IsPost) {
+ var newTags = Request["newTags"];
+ // prepare tags for processing
+ var tagNames = newTags.Split(';');
+
+ //Clear Tags associated with this image
+ db.Execute("DELETE FROM Photos_Tags WHERE Photos_Id = @0", photoId);
+ foreach (string tagName in tagNames) {
+ // get the tag ID for each tag, else create if doesn't exist
+ var trimmed = tagName.Trim();
+ bool exists = db.QueryValue("SELECT COUNT(*) FROM Tags WHERE TagName = @0", trimmed) > 0;
+ if (!exists) {
+ //If tag doesn't exist, create it
+ db.Execute("INSERT INTO Tags (TagName) VALUES (@0)", trimmed);
+ }
+ //Associate image and tag
+ db.Execute("INSERT INTO Photos_Tags (Photos_Id, Tags_TagName) VALUES (@0, @1)", photoId, trimmed);
+ }
+ Response.Redirect(Href("View", photo.Id));
+ }
+
+ // get a list of all the tags for this photo, sorted
+ var tags = db.Query("SELECT TagName FROM Tags, Photos_Tags WHERE Tags_TagName = TagName AND Photos_Id = @0 ORDER BY TagName", photoId);
+
+ var tagsList = new List<string>();
+ foreach (var tag in tags) {
+ tagsList.Add(tag.TagName);
+ }
+ var tagStringToDisplay = String.Join("; ", tagsList.ToArray());
+}
+
+<div class="sidebar">
+ <h1>Edit Photo's Tags</h1>
+ <h2>@photo.FileTitle</h2>
+ <form method="post" action="">
+ <fieldset class="no-legend">
+ <legend>Edit Tags</legend>
+ <ol>
+ <li>
+ <label for="newTags">Enter tags, semicolon-delimited:</label>
+ <textarea id="newTags" name="newTags" title="Enter tags seperated by a semicolon" rows="4" cols="50" placeholder="Enter tags seperated by a semicolon">@tagStringToDisplay</textarea>
+ </li>
+ </ol>
+ <p class="form-actions">
+ <input type="submit" value="Save Changes" title="Save changes" />
+ <a href="@Href("~/Photo/View", photoId)" title="Do not save changes">Cancel</a>
+ </p>
+ </fieldset>
+ </form>
+</div>
+<div class="main">
+ <img alt="@Html.AttributeEncode(photo.FileTitle)" src="@Href("~/Photo/Thumbnail", photo.Id, new { size="large" })" />
+</div>
View
15 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/Full.cshtml
@@ -0,0 +1,15 @@
+@{
+ // Cache the image for a minute
+ Response.OutputCache(60);
+
+ var photoId = UrlData[0].AsInt();
+ var db = Database.Open("PhotoGallery");
+ var photo = db.QuerySingle("SELECT * FROM Photos WHERE Id = @0", photoId);
+ if (photo == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ Response.AppendHeader("Content-Disposition", String.Format("attachment; filename={0}", HttpUtility.UrlPathEncode(photo.FileTitle + photo.FileExtension)));
+ new WebImage(photo.FileContents).Write();
+}
View
51 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/OrderSuccess.cshtml
@@ -0,0 +1,51 @@
+<div class="receipt">
+@{
+
+ var shippirngAddress = Request["shippingAddress"];
+ var qty = "1";
+ var price = new Decimal(1);
+ var publisher = "mytest_1296498503_biz@yahoo.com";
+ var printer = "isv_1284493468_biz@yahoo.com";
+ var developer = "msft_1284494024_biz@yahoo.com";
+
+ var DevRcv = new PayPal.AdaptivePayments.Receiver();
+ DevRcv.email = developer;
+ DevRcv.amount = price;
+
+ var PayReceivers = new List<PayPal.AdaptivePayments.Receiver>();
+
+ var PubRcv = new PayPal.AdaptivePayments.Receiver();
+ PubRcv.email = publisher;
+ PubRcv.amount = decimal.Round(price * .10m, 2);
+ PayReceivers.Add(PubRcv);
+
+ var PrintRcv = new PayPal.AdaptivePayments.Receiver();
+ PrintRcv.email = printer;
+ PrintRcv.amount = decimal.Round(price * .70m, 2);
+ PayReceivers.Add(PrintRcv);
+
+ var Language = "en_US";
+ var CancelUrl = "http://localhost:27359"; //Change the domain and port to your environment
+ var ReturnUrl = "http://localhost:27359"; //Change the domain and port to your environment
+ var CurrencyCode = "USD";
+
+ var response = PayPal.AdaptivePayments.ChainedPay.Execute
+ (DevRcv, PayReceivers, "", "Test Photo Payment", "127.0.0.1", "MyDevice",CancelUrl,ReturnUrl,"",CurrencyCode,Language);
+
+ if (response == null) {
+ Response.Write("null");
+ }
+ else
+ {
+ Response.Write("full");
+ }
+
+ var payKey = response.payKey;
+
+ //Points to the paypal sandbox account. Change it to production url for live.
+ var redirectUrl = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" + payKey;
+
+ Response.Redirect(redirectUrl);
+
+}
+</div>
View
45 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/Remove.cshtml
@@ -0,0 +1,45 @@
+@{
+ var photoId = UrlData[0].AsInt();
+
+ var db = Database.Open("PhotoGallery");
+
+ var photo = db.QuerySingle("SELECT * FROM Photos WHERE Id = @0", photoId);
+ if (photo == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ WebSecurity.RequireUser(photo.UserId);
+
+ Page.Title = "Remove Photo - " + photo.FileTitle;
+
+ if (IsPost) {
+ //Remove all tags associated with this image
+ db.Execute("DELETE FROM Photos_Tags WHERE Photos_Id = @0", photoId);
+ //Remove all comments associated with this image
+ db.Execute("DELETE FROM Comments WHERE PhotoId = @0", photoId);
+ //Delete image
+ db.Execute("DELETE FROM Photos WHERE Id = @0", photoId);
+ Response.Redirect(Href("~/Gallery/View",photo.GalleryId));
+ }
+}
+
+<div class="sidebar">
+ <h1>@photo.FileTitle</h1>
+ <h2 class="confirm-removal">Confirm Removal</h2>
+ <p class="message error">
+ Removing this photo will permanently delete the file from the photo gallery site
+ and you will lose all associated data (description, tags, and comments). You may
+ want to download the <a href="@Href("~/Photo/Full", photoId)" title="Download: @(photo.FileTitle + photo.FileExtension)">full size photo</a> before continuing.
+ </p>
+
+ <form method="post" action="">
+ <p class="form-actions">
+ <input type="submit" value="Remove" title="Remove photo" />
+ <a href="@Href("~/Photo/View", photoId)" title="Do not remove photo">Cancel</a>
+ </p>
+ </form>
+</div>
+<div class="main">
+ <img src="@Href("~/Photo/Thumbnail", photo.Id, new { size="large" })" />
+</div>
View
38 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/Thumbnail.cshtml
@@ -0,0 +1,38 @@
+@{
+ // Cache the image for a minute
+ Response.OutputCache(60);
+
+ var photoId = UrlData[0].AsInt();
+ var db = Database.Open("PhotoGallery");
+ var photo = db.QuerySingle("SELECT * FROM Photos WHERE Id = @0", photoId);
+ if (photo == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ var size = Request["size"] ?? "";
+
+ var width = 0;
+ var height = 0;
+ switch (size.ToUpperInvariant()) {
+ case "":
+ case "SMALL":
+ width = 200;
+ height = 200;
+ break;
+ case "MEDIUM":
+ width = 400;
+ height = 300;
+ break;
+ case "LARGE":
+ width = 625;
+ height = 625;
+ break;
+ default:
+ Response.SetStatus(HttpStatusCode.BadRequest);
+ return;
+ }
+
+ var image = new WebImage(photo.FileContents);
+ image.Resize(width, height).Write();
+}
View
146 OrlandoCodeCamp/PhotoSharing-PayPal/Photo/View.cshtml
@@ -0,0 +1,146 @@
+@{
+ var photoId = UrlData[0].AsInt();
+
+ var db = Database.Open("PhotoGallery");
+
+ var photo = db.QuerySingle("SELECT * FROM Photos WHERE Id = @0", photoId);
+ if (photo == null) {
+ Response.SetStatus(HttpStatusCode.NotFound);
+ return;
+ }
+
+ Page.Title = "Photo - " + photo.FileTitle;
+
+ string description = photo.description;
+
+ if (IsPost) {
+ var newComment = Request["newComment"].Trim();
+ if (newComment.IsEmpty()) {
+ Response.Redirect(Href("View", photoId));
+ }
+
+ db.Execute("INSERT INTO Comments (PhotoId, CommentDate, UserId, CommentText) VALUES (@0, @1, @2, @3)",
+ photoId, DateTime.Now, WebSecurity.CurrentUserId, newComment);
+
+ Response.Redirect(Href("View",photoId));
+ return;
+ }
+
+ // Found a match - so show its info
+ var user = db.QuerySingle("SELECT * FROM UserProfiles WHERE UserId = @0", photo.UserId);
+ var gallery = db.QuerySingle("SELECT * FROM Galleries WHERE Id = @0", photo.GalleryId);
+ var comments = db.Query(@"SELECT * FROM Comments INNER JOIN UserProfiles
+ ON Comments.UserId = UserProfiles.UserId WHERE PhotoId = @0 ORDER BY Comments.CommentDate", photo.Id);
+ var tagList = db.Query("SELECT Tags_TagName FROM Photos_Tags WHERE Photos_Id = @0 ORDER BY Tags_TagName", photo.Id);
+}
+
+<div class="sidebar">
+ <h1>@photo.FileTitle</h1>
+ @if (user.UserId == WebSecurity.CurrentUserId) {
+ <p>
+ As the author, you can <a href="@Href("~/Photo/Edit", photoId)">edit</a>
+ or <a href="@Href("~/Photo/Remove", photoId)">remove</a> this photo.
+ </p>
+ }
+ <dl>
+ <dt class="description">Description</dt>
+ <dd class="description">
+ @if (!description.IsEmpty()) {
+ <text>@photo.Description</text>
+ } else {
+ <text>The uploader did not provide a description for this photo.</text>
+ }
+ </dd>
+ <dt class="uploaded-by">Uploaded by</dt>
+ <dd class="uploaded-by"><a href="@Href("~/User/View", user.UserId)">@user.DisplayName</a></dd>
+ <dt class="upload-date">Upload date</dt>
+ <dd class="upload-date">@photo.UploadDate</dd>
+ <dt class="part-of-gallery">Gallery</dt>
+ <dd><a href="@Href("~/Gallery/View", gallery.Id)" title="View @gallery.Name gallery">@gallery.Name</a></dd>
+ <dt class="tags">Tags</dt>
+ <dd class="tags">
+ <ul class="tags">
+ @if (tagList.Count == 0) {
+ <li>This photo has no tags.</li>
+ } else {
+ foreach (var t in tagList) {
+ <li class="tag"><a href="@Href("~/Tag/View", t.Tags_TagName)">@t.Tags_TagName</a></li>
+ }
+ }
+ </ul>
+ @if (WebSecurity.IsAuthenticated) {
+ <a href="@Href("~/Photo/EditTags", photoId)">edit tags</a>
+ }
+ </dd>
+ </dl>
+
+ <p>
+ <a class="download" href="@Href("~/Photo/Full", photoId)" title="Download: @(photo.FileTitle + photo.FileExtension)">Download full photo</a> (@(photo.FileSize / 1024) KB)
+ </p>
+</div>
+
+<div id="paypal">
+
+ Order this Print for just $1
+
+ <form name"frmPayPal" action="/Photo/OrderSuccess">
+ <input type="hidden" name="publisher" value="@user.Email">
+ Shipping Address : <input type="text" name="shippingAddress" value=""/><br/><br/>
+ <input type="submit" value="Buy"/>
+ </form>
+
+ @Facebook.LikeButton("http://www.paypal.com")
+
+</div>
+
+
+
+
+<div class="main">
+ <img class="large-photo" alt="@Html.AttributeEncode(photo.FileTitle)" src="@Href("~/Photo/Thumbnail", photo.Id, new { size="large" })" />
+
+ @switch ((int)comments.Count) {
+ case 0:
+ <h2>Nobody has commented on this photo</h2>
+ break;
+ case 1:
+ <h2>This photo has generated one comment.</h2>
+ break;
+ default:
+ <h2>This photo has generated @comments.Count comments.</h2>
+ break;
+ }
+
+ <ol class="comments">
+ @foreach (var comment in comments) {
+ <li>
+ <h3 class="comment-header">
+ <a href="@Href("~/User/View", comment.UserId)" title="View @(comment.DisplayName)'s profile">@comment.DisplayName</a> commented at @comment.CommentDate:
+ </h3>
+ <p class="comment-body">@comment.CommentText</p>
+ </li>
+ }
+ </ol>
+
+ @if (WebSecurity.IsAuthenticated) {
+ <form method="post" action="">
+ <fieldset id="addComment">
+ <legend>Post new comment</legend>
+ <ol>
+ <li>
+ <label for="newComment">Comment</label>
+ <textarea id="newComment" name="newComment" title="Your comment" rows="6" cols="70"></textarea>
+ </li>
+ </ol>
+ <p class="form-actions">
+ <input type="submit" title="Add comment" value="Add comment" />
+ </p>
+ </fieldset>
+ </form>
+ } else {
+ <p>
+ Only registered user may leave comments. Please <a href="@Href("~/Account/Login")">login</a>
+ or <a href="@Href("~/Account/Register")">create an account</a> to leave a comment.
+ </p>
+ }
+</div>
View
456 OrlandoCodeCamp/PhotoSharing-PayPal/Styles/Site.css
@@ -0,0 +1,456 @@
+/* Reset default styles
+-------------------------------------------------------*/
+body {
+ background-color: #eaeeef;
+ margin: 0;
+ padding: 0;
+ font-family: "Segoe UI", Tahoma, Verdana, Arial, Sans-Serif;
+ color: #343434;
+ min-width: 960px;
+}
+
+a {
+ color: #1170a9;
+ text-decoration: none;
+}
+
+a:hover {
+ color: #0d527b;
+}
+
+h1, h2, h3, h4, h5, h6 {
+ font-weight: normal;
+}
+
+h1, h2, h3 {
+ margin: 0;
+ padding: 0;
+}
+
+h2 {
+ font-size: 1.2em;
+}
+
+h3 {
+ font-size: 1.1em;
+}
+
+p {
+ padding: 10px 0;
+ margin: 0;
+}
+
+dl {
+ margin: 0;
+}
+
+ dt {
+ font-weight: bold;
+ }
+
+ dt:after {
+ content: ":";
+ }
+
+ dd {
+ margin-left: 5px;
+ font-size: .85em;
+ margin-bottom: 5px;
+ }
+
+
+/* Basic Layout
+-------------------------------------------------------*/
+#banner {
+ padding: 20px 20px 0 20px;
+ height: 60px;
+ background: #eaeaea url("../Images/header-bkg.png") repeat-x left bottom;
+ font-family: Tahoma;
+ border-bottom: 1px solid #e0e0e0;
+
+ /*CSS3 properties*/
+ text-shadow: -1px 1px 1px #fff;
+}
+
+ .site-title {
+ margin: 0;
+ padding: 0;
+ font-size: 1.75em;
+ display: inline;
+ }
+
+ .site-title a {
+ color: #2f5163;
+ }
+
+#page {
+ padding: 20px 15px;
+}
+
+#footer {
+ clear: both;
+ border-top: 1px dotted #c7ccd3;
+ margin: 20px 0 20px 0;
+ padding: 20px 0 20px 0;
+ font-size: 0.8em;
+ text-align: center;
+ color: #343434;
+}
+
+
+ /* Menu
+ ----------*/
+ #menu {
+ padding: 0;
+ margin: 0 0 0 60px;
+ display: inline;
+ }
+
+ #menu li {
+ padding: 0;
+ margin: 0 24px 0 0;
+ display: inline;
+ }
+
+ #menu li a {
+ padding: 12px 12px 12px 40px;
+ color: #0F6395;
+ }
+
+ #menu li a:hover {
+ color: #09354f;
+ }
+
+ #menu li.galleries a {
+ background: url("../Images/icon-gallery.png") no-repeat 0 50%;
+ }
+
+ #menu li.tags a {
+ background: url("../Images/icon-tags.png") no-repeat 0 50%;
+ }
+
+ #menu li.account a {
+ background: url("../Images/icon-account.png") no-repeat 0 50%;
+ }
+
+ #menu li.login {
+ margin-left: 0;
+ font-size: .75em;
+ }
+
+ #menu li.login a {
+ padding: 0;
+ }
+
+ #menu li.login a:before {
+ content: "[";
+ padding-right: 3px;
+ }
+
+ #menu li.login a:after {
+ content: "]";
+ padding-left: 3px;
+ }
+
+/* Shared Layout
+-------------------------------------------------------*/
+div.sidebar {
+ float: left;
+ width: 30%;
+ margin-right: 30px;
+ height: 100%;
+
+ /*CSS3 properties*/
+ word-wrap: break-word;
+}
+
+div.main {
+ float: left;
+ width:65%;
+}
+
+/* Thumbnail Layout
+-------------------------------------------------------*/
+ul.thumbnails {
+ margin:0;
+ padding:0;
+}
+ul.thumbnails li {
+ position: relative;
+ list-style: none;
+ float: left;
+ margin: 8px;
+ padding: 5px;
+ font-size: small;
+ text-align: center;
+ border: 1px solid transparent;
+ width: 202px;
+ height: 202px;
+ line-height: 200px;
+ display: block;
+}
+
+ul.gallery li {
+ height: 220px;
+}
+
+ ul.thumbnails li span {
+ display: block;
+ }
+
+ ul.thumbnails li span.image-overlay {
+ display: none;
+ width: 200px;
+ padding: 5px;
+ background-color: #fff;
+ color: #343434;
+
+ /*CSS3 properties*/
+ border-radius: 7px 7px 0 0;
+ -moz-border-radius: 7px 7px 0 0;
+ -webkit-border-radius: 7px 7px 0 0;
+ background-color: rgba(255, 255, 255, 0.75);
+ word-wrap: break-word;
+ }
+
+ ul.thumbnails li span.below-image {
+ line-height: normal;
+ }
+
+ ul.thumbnails li img {
+ margin: auto;
+ display: inline;
+ vertical-align: middle;
+ }
+
+ul.thumbnails li:hover {
+ background: #f3f6f7;
+ border-color: #dbe2e5;
+
+ /*CSS3 properties*/
+ border-radius: 7px;
+ -moz-border-radius: 7px;
+ -webkit-border-radius: 7px;
+ box-shadow: 0px 0px 10px #d0d0d0;
+ -moz-box-shadow: 0px 0px 10px #d0d0d0;
+ -webkit-box-shadow: 0px 0px 10px #d0d0d0;
+}
+
+ ul.thumbnails li:hover span.image-overlay {
+ display: block;
+ position: absolute;
+ top: 0;
+ left: 0;
+ line-height: normal;
+ }
+
+/* Single Photo Layout
+--------------------------------------------------*/
+/* Sidebar
+-------------*/
+dd.tags {
+ margin: 5px;
+}
+
+ ul.tags {
+ list-style: none;
+ display: inline;
+ padding: 0;
+ margin: 0;
+ }
+
+ ul.tags li {
+ display:inline;
+ padding: 1px 5px;
+ color: #fff;
+ background-color: #757575;
+
+ /*CSS3 properties*/
+ border-radius: 3px;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ }
+
+ ul.tags li a {
+ color: #fff;
+ }
+
+ ul.tags li:hover {
+ background-color: #444;
+ }
+
+.download {
+ font-size: 1.1em;
+ padding-left: 20px;
+ background: url("../Images/download.png") no-repeat left;
+}
+
+/* Main
+----------*/
+ol.comments {
+ font-size: .85em;
+ padding: 0;
+ list-style: none;
+}
+
+ ol.comments h3 {
+ margin-top: 5px;
+ font-weight: bold;
+ border-bottom: 1px solid #dbe2e5;
+ }
+
+ ol.comments p {
+ padding: 0 0 0 5px;
+ }
+
+#addComment textarea {
+ width: 100%;
+}
+
+/* Forms
+----------------------------------------------------------*/
+fieldset {
+ margin: 1em 0;
+ padding: 1em;
+ border: 1px solid #ccc;
+}
+
+ fieldset legend {
+ font-size: 1.1em;
+ font-weight: bold;
+ padding: 2px 4px 8px 4px;
+ }
+
+ fieldset ol {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+ }
+
+ fieldset ol li {
+ padding-bottom: 5px;
+ }
+
+ fieldset label {
+ display: block;
+ }
+
+ fieldset label.checkbox {
+ display: inline;
+ }
+
+ fieldset input[type="text"], input[type="password"] {
+ border: 1px solid #ccc;
+ padding: 2px;
+ font-size: 1.2em;
+ color: #444;
+ width: 300px;
+ }
+
+ fieldset input[type="submit"] {
+ padding: 5px;
+ }
+
+ fieldset textarea {
+ color: #444;
+ width: 300px;
+ }
+
+ .no-legend {
+ border: none;
+ padding: 0;
+ }
+
+ .no-legend legend {
+ display: none;
+ }
+
+fieldset input[type="text"].input-validation-error,
+input[type="password"].input-validation-error,
+.input-validation-error {
+ border: 1px solid #be3e16;
+ background-color: #ffe4e4;
+}
+
+.field-validation-error {
+ display: block;
+ color: #be3e16;
+ font-weight: bold;
+}
+
+.validation-summary-errors {
+ color: #be3e16;
+ font-weight: bold;
+}
+
+.validation-summary-errors ul {
+ list-style: none;
+ padding: 0;
+ margin: 0
+}
+
+/* Misc
+----------------------------------------------------------*/
+.similar-tags {
+ clear: both;
+ font-weight: bold;
+ margin: 5px;
+}
+
+.user-photos {
+ padding: 0;
+ margin: 0;
+}
+
+.confirm-removal {
+ color: #d63301;
+}
+
+ .large-photo {
+ margin: 10px 0;
+ }
+
+.thumbnail-border, .large-photo {
+ border: 1px solid #dbe2e5;
+ display: block;
+}
+
+.thumbnail-no-border {
+ border: none;
+ display: block;
+}
+
+#file-upload-buttons input[type=submit] {
+ display: block;
+ font-size: 1.2em;
+ padding: 5px;
+}
+
+.actions {
+ clear: both;
+}
+
+.message {
+ clear: both;
+ border: 1px solid;
+ margin: 10px 0px;
+ padding: 15px 15px;
+
+ /*CSS3 properties*/
+ border-radius: 4px;
+ -moz-border-radius: 4px;
+ -webkit-border-radius: 4px;
+ box-shadow: 2px 2px 5px #888;
+ -webkit-box-shadow: 2px 2px 5px #888;
+ -moz-box-shadow: 2px 2px 5px #888;
+}
+
+.info {
+ background: #bde5f8;
+ color: #00529b;
+}
+
+.error {
+ background: #ffe4e4;
+ color: #be3e16;
+}
View
30 OrlandoCodeCamp/PhotoSharing-PayPal/Tag/Default.cshtml
@@ -0,0 +1,30 @@
+@{
+ Page.Title = "View All Tags";
+
+ var db = Database.Open("PhotoGallery");
+
+ var tags = db.Query(@"SELECT Tags_TagName AS TagName, COUNT(*) AS TagCount
+ FROM Photos_Tags
+ GROUP BY Tags_TagName
+ ORDER BY Tags_TagName").ToList();
+}
+
+<h1>Tags</h1>
+
+@if (tags.Count == 1) {
+ <p>There is one tag.</p>
+} else {
+ <p>There are @tags.Count tags.</p>
+}
+
+<ul class="thumbnails gallery">
+ @foreach (var tag in tags) {
+ <li class="tag">
+ <a href="@Href("~/Tag/View", tag.TagName)">
+ <img alt="Images from @tag.TagName" src="@Href("~/Tag/Thumbnail", tag.TagName)" class="thumbnail-no-border" />
+ <span class="below-image">@tag.TagName</span>
+ <span class="image-overlay">@tag.TagCount photo(s)</span>
+ </a>
+ </li>
+ }
+</ul>
View
33 OrlandoCodeCamp/PhotoSharing-PayPal/Tag/Thumbnail.cshtml
@@ -0,0 +1,33 @@
+@{
+ // Cache the image for a minute
+ Response.OutputCache(60);
+
+ var tagName = UrlData[0];
+
+ var db = Database.Open("PhotoGallery");
+ var tag = db.Query("SELECT TagName FROM Tags WHERE TagName = @0", tagName);
+ var photoList = db.Query(@"SELECT TOP(3) Photos.FileContents
+ FROM Photos, Photos_Tags
+ WHERE Photos.Id = Photos_Tags.Photos_Id AND Photos_Tags.Tags_TagName = @0", tagName).Shuffle().ToList();
+
+ if (tag != null && photoList.Count > 0) {
+ using (MultiThumbnailGenerator generator = new MultiThumbnailGenerator()) {
+ foreach (var photo in photoList) {
+ using (var imageStream = new System.IO.MemoryStream(photo.FileContents)) {
+ using (var image = System.Drawing.Image.FromStream(imageStream)) {
+ generator.AddImage(image);
+ }
+ }
+ }
+
+ using (var outStream = new System.IO.MemoryStream()) {
+ generator.WritePngToStream(outStream);
+ var image = new WebImage(outStream);
+ image.Write();
+ }
+ }
+ } else {
+ // no photos - hopefully user will never see this
+ Response.Redirect("~/Shared/gallery-empty.png");
+ }
+}
View
45 OrlandoCodeCamp/PhotoSharing-PayPal/Tag/View.cshtml
@@ -0,0 +1,45 @@
+@{
+ var tagName = UrlData[0];
+ Page.Title = "View Tag - " + tagName;
+
+ var db = Database.Open("PhotoGallery");
+ var photos = db.Query(@"SELECT Photos.Id, Photos.FileTitle
+ FROM Photos, Photos_Tags
+ WHERE Photos.Id = Photos_Tags.Photos_Id AND Photos_Tags.Tags_TagName = @0", tagName).ToList();
+ var similarTags = db.Query(@"SELECT Tags_TagName AS TagName, COUNT(*) AS Count
+ FROM Photos_Tags WHERE Photos_Id IN (SELECT Photos_Id FROM Photos_Tags WHERE Tags_TagName = @0) AND Tags_TagName != @0
+ GROUP BY Tags_TagName
+ ORDER BY Count DESC", tagName).ToList();
+}
+
+<h1>@tagName</h1>
+
+@if (photos.Count == 0) {
+ <p>There are no photos with this tag.</p>
+} else {
+ if (photos.Count == 1) {
+ <p>There is one photo with this tag.</p>
+ } else {
+ <p>There are @photos.Count photos with this tag.</p>