Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/UI/Web/App_Data/GiveIT.mdf
Binary file not shown.
Binary file added src/UI/Web/App_Data/GiveIT_log.ldf
Binary file not shown.
Binary file modified src/UI/Web/App_Data/aspnet-GiveIT.UI.Web-20130520184752.mdf
Binary file not shown.
Binary file modified src/UI/Web/App_Data/aspnet-GiveIT.UI.Web-20130520184752_log.ldf
Binary file not shown.
8 changes: 3 additions & 5 deletions src/UI/Web/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
using DotNetOpenAuth.AspNet;
using Microsoft.Web.WebPages.OAuth;
using WebMatrix.WebData;
using GiveIT.UI.Web.Filters;
using GiveIT.UI.Web.Models;

namespace GiveIT.UI.Web.Controllers
{
[Authorize]
[InitializeSimpleMembership]
public class AccountController : Controller
{
//
Expand Down Expand Up @@ -264,14 +262,14 @@ public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model,
if (ModelState.IsValid)
{
// Insert a new user into the database
using (UsersContext db = new UsersContext())
using (UIWebDbContext db = new UIWebDbContext())
{
UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
User user = db.Users.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
// Check if user already exists
if (user == null)
{
// Insert name into the profile table
db.UserProfiles.Add(new UserProfile { UserName = model.UserName });
db.Users.Add(new User { UserName = model.UserName });
db.SaveChanges();

OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, model.UserName);
Expand Down
133 changes: 133 additions & 0 deletions src/UI/Web/Controllers/CharityRegisterController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
using GiveIT.UI.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using WebMatrix.WebData;

namespace GiveIT.UI.Web.Controllers
{
public class CharityRegisterController : Controller
{
UIWebDbContext db = new UIWebDbContext();


//
// GET: /CharityRegister/RegisterC
[AllowAnonymous]
public ActionResult RegisterC()
{
return View();
}

//
// POST: /CharityRegister/RegisterC

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult RegisterC(CharityRegister model)
{

if (ModelState.IsValid)
{
// Attempt to register the charity and store charity info to database
try
{

WebSecurity.CreateUserAndAccount(model.CharityName, model.Password,
propertyValues: new
{
ContactFirstName = model.ContactFirstName,
ContactLastName = model.ContactLastName,
Title = model.Title,
PhoneNumber = model.PhoneNumber,
PhoneNoExtension = model.PhoneNoExtension,
EmailAddress = model.EmailAddress
});

db.Charities.Add(new Charity
{
CharityName = model.CharityName,
MissionAndLocation = model.MissionAndLocation,
EIN = model.EIN,
StreetAddress = model.StreetAddress,
StreetAddress2 = model.StreetAddress2,
City = model.City,
State = model.State,
ZipCode = model.ZipCode
});

db.SaveChanges();

WebSecurity.Login(model.CharityName, model.Password);


///////////////-Just test page, need to redirect to somewhere
return RedirectToAction("Index", "Home");
// return RedirectToAction("Detail", "RegisterC");
}
catch (MembershipCreateUserException e)
{
ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
}
}

// If we got this far, something failed, redisplay form
return View(model);
}


#region Helpers
private static string ErrorCodeToString(MembershipCreateStatus createStatus)
{
// See http://go.microsoft.com/fwlink/?LinkID=177550 for
// a full list of status codes.
switch (createStatus)
{
case MembershipCreateStatus.DuplicateUserName:
return "User name already exists. Please enter a different user name.";

case MembershipCreateStatus.DuplicateEmail:
return "A user name for that e-mail address already exists. Please enter a different e-mail address.";

case MembershipCreateStatus.InvalidPassword:
return "The password provided is invalid. Please enter a valid password value.";

case MembershipCreateStatus.InvalidEmail:
return "The e-mail address provided is invalid. Please check the value and try again.";

case MembershipCreateStatus.InvalidAnswer:
return "The password retrieval answer provided is invalid. Please check the value and try again.";

case MembershipCreateStatus.InvalidQuestion:
return "The password retrieval question provided is invalid. Please check the value and try again.";

case MembershipCreateStatus.InvalidUserName:
return "The user name provided is invalid. Please check the value and try again.";

case MembershipCreateStatus.ProviderError:
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

case MembershipCreateStatus.UserRejected:
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

default:
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
}
}
#endregion

protected override void Dispose(bool disposing)
{
if (db != null)
{
db.Dispose();
}
base.Dispose(disposing);
}

}
}
12 changes: 7 additions & 5 deletions src/UI/Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using GiveIT.UI.Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
Expand All @@ -8,16 +9,15 @@ namespace GiveIT.UI.Web.Controllers
{
public class HomeController : Controller
{

public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

return View();
}

public ActionResult HowItWorks()
public ActionResult About()
{
//ViewBag.Message = "Your app description page.";
ViewBag.Message = "Your app description page.";

return View();
}
Expand All @@ -28,5 +28,7 @@ public ActionResult Contact()

return View();
}


}
}
50 changes: 0 additions & 50 deletions src/UI/Web/Filters/InitializeSimpleMembershipAttribute.cs

This file was deleted.

2 changes: 2 additions & 0 deletions src/UI/Web/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using WebMatrix.WebData;

namespace GiveIT.UI.Web
{
Expand All @@ -16,6 +17,7 @@ public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);
AreaRegistration.RegisterAllAreas();

WebApiConfig.Register(GlobalConfiguration.Configuration);
Expand Down
Binary file removed src/UI/Web/Images/howItWorks.png
Binary file not shown.
27 changes: 27 additions & 0 deletions src/UI/Web/Migrations/201307041906449_InitialCreate.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions src/UI/Web/Migrations/201307041906449_InitialCreate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace GiveIT.UI.Web.Migrations
{
using System;
using System.Data.Entity.Migrations;

public partial class InitialCreate : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.UserProfile",
c => new
{
UserId = c.Int(nullable: false, identity: true),
UserName = c.String(),
ContactFirstName = c.String(),
ContactLastName = c.String(),
PhoneNumber = c.String(),
PhoneNoExtension = c.String(),
EmailAddress = c.String(),
})
.PrimaryKey(t => t.UserId);

CreateTable(
"dbo.Charity",
c => new
{
UserId = c.Int(nullable: false),
CharityId = c.Int(nullable: false, identity: true),
CharityName = c.String(),
MissionAndLocation = c.String(),
EIN = c.String(),
StreetAddress = c.String(),
StreetAddress2 = c.String(),
City = c.String(),
State = c.String(),
ZipCode = c.String(),
})
.PrimaryKey(t => t.UserId)
.ForeignKey("dbo.UserProfile", t => t.UserId)
.Index(t => t.UserId);

}

public override void Down()
{
DropIndex("dbo.Charity", new[] { "UserId" });
DropForeignKey("dbo.Charity", "UserId", "dbo.UserProfile");
DropTable("dbo.Charity");
DropTable("dbo.UserProfile");
}
}
}
Loading