Restyle login, change password works

This commit is contained in:
2012-12-22 10:48:34 -05:00
parent f129142dab
commit c1944f6262
54 changed files with 327 additions and 255 deletions
Binary file not shown.
@@ -1,6 +1,7 @@
using System;
using MileageTraker.Web.Models;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.CreateLog;
using NUnit.Framework;
namespace Web.Tests.ViewModels
+39
View File
@@ -0,0 +1,39 @@
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}
.header {
background: url(images/Header.login.png) no-repeat;
height: 54px;
width: 300px;
}
.form-login {
max-width: 300px;
padding: 19px 29px 29px;
margin: 0 auto 20px;
background-color: #fff;
border: 1px solid #e5e5e5;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.validation-summary-errors ul {
list-style-type: none;
margin: 0;
}
.rememberMe {
margin-bottom: 20px;
}
legend {
border-bottom: 0;
margin-bottom: 0;
}
+37
View File
@@ -2,6 +2,10 @@
padding-top: 60px;
}
.navbar.navbar-fixed-top {
min-width: 979px
}
.brand
{
background: url(images/Header.png) no-repeat left center;
@@ -18,6 +22,29 @@
line-height: 29px;
}
.nav > li button.btn-link {
display: block;
}
.navbar .nav > li button.btn-link {
float: none;
padding: 12px 15px 0;
color: #777;
text-decoration: none;
}
.navbar-inverse .nav > li button.btn-link {
color: #999;
}
.navbar-inverse .nav > li button.btn-link:hover {
color: white;
}
.navbar .nav > li form {
margin: 0;
}
footer {
background-color: #101010;
color: #666;
@@ -35,6 +62,16 @@ footer {
margin-left: 120px;
}
fieldset legend {
margin: 0;
border: 0;
}
.validation-summary-errors ul {
list-style-type: none;
margin: 0;
}
.report-calculation
{
display: none;
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

+2 -1
View File
@@ -3,6 +3,7 @@ using System.Web.Mvc;
using System.Web.Security;
using MileageTraker.Web.Membership;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.Account;
namespace MileageTraker.Web.Controllers
{
@@ -97,7 +98,7 @@ namespace MileageTraker.Web.Controllers
{
changePasswordSucceeded = WebSecurity.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword);
}
catch (Exception)
catch (Exception ex)
{
changePasswordSucceeded = false;
}
+1
View File
@@ -4,6 +4,7 @@ using MileageTraker.Web.DAL;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.CreateLog;
namespace MileageTraker.Web.Controllers
{
+2
View File
@@ -5,6 +5,8 @@ using MileageTraker.Web.DAL;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.Log;
using MileageTraker.Web.ViewModels.Vehicle;
namespace MileageTraker.Web.Controllers
{
+1
View File
@@ -3,6 +3,7 @@ using System.Web.Mvc;
using MileageTraker.Web.DAL;
using MileageTraker.Web.Models;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.Vehicle;
namespace MileageTraker.Web.Controllers
{
+2 -1
View File
@@ -8,6 +8,8 @@ using MileageTraker.Web.Context;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.Log;
using MileageTraker.Web.ViewModels.Vehicle;
namespace MileageTraker.Web.DAL
{
@@ -172,7 +174,6 @@ namespace MileageTraker.Web.DAL
});
}
public IEnumerable<EmployeeMileageItem> GetMonthlyEmployeeMileageItems(LogQueryViewModel query)
{
var items =
+44 -60
View File
@@ -1,5 +1,5 @@
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
@@ -18,7 +18,11 @@ namespace MileageTraker.Web.Membership
public override string ApplicationName
{
get { return GetType().Assembly.GetName().Name; }
set { ApplicationName = GetType().Assembly.GetName().Name; }
set
{
if (value == null) throw new ArgumentNullException("value");
ApplicationName = GetType().Assembly.GetName().Name;
}
}
public override int MaxInvalidPasswordAttempts
@@ -113,24 +117,19 @@ namespace MileageTraker.Web.Membership
PasswordFailuresSinceLastSuccess = 0,
LastLoginDate = DateTime.UtcNow,
LastActivityDate = DateTime.UtcNow,
LastLockoutDate = DateTime.UtcNow,
LastLockoutDate = SqlDateTime.MinValue.Value,
IsLockedOut = false,
LastPasswordFailureDate = DateTime.UtcNow
LastPasswordFailureDate = SqlDateTime.MinValue.Value
};
context.Users.Add(newUser);
context.SaveChanges();
status = MembershipCreateStatus.Success;
return new MembershipUser(System.Web.Security.Membership.Provider.Name, newUser.Username, newUser.UserId,
newUser.Email, null, null,
newUser.IsApproved, newUser.IsLockedOut, newUser.CreateDate.Value,
newUser.LastLoginDate.Value, newUser.LastActivityDate.Value,
newUser.LastPasswordChangedDate.Value, newUser.LastLockoutDate.Value);
return newUser.CloneToMembershipUser(System.Web.Security.Membership.Provider.Name);
}
}
public string CreateUserAndAccount(string userName, string password, bool requireConfirmation,
IDictionary<string, object> values)
public string CreateUserAndAccount(string userName, string password, bool requireConfirmation)
{
return CreateAccount(userName, password, requireConfirmation);
}
@@ -196,7 +195,7 @@ namespace MileageTraker.Web.Membership
}
using (var context = new MileageTrakerContext())
{
User user = context.Users.FirstOrDefault(Usr => Usr.Username == username);
var user = context.Users.FirstOrDefault(usr => usr.Username == username);
if (user == null)
{
return null;
@@ -207,12 +206,7 @@ namespace MileageTraker.Web.Membership
user.LastActivityDate = DateTime.UtcNow;
context.SaveChanges();
}
return new MembershipUser(System.Web.Security.Membership.Provider.Name, user.Username, user.UserId, user.Email,
null, null,
user.IsApproved, user.IsLockedOut, user.CreateDate.Value, user.LastLoginDate.Value,
user.LastActivityDate.Value, user.LastPasswordChangedDate.Value,
user.LastLockoutDate.Value);
return user.CloneToMembershipUser(System.Web.Security.Membership.Provider.Name);
}
}
@@ -228,8 +222,7 @@ namespace MileageTraker.Web.Membership
using (var context = new MileageTrakerContext())
{
User user;
user = context.Users.Find(providerUserKey);
var user = context.Users.Find(providerUserKey);
if (user == null)
{
return null;
@@ -240,12 +233,7 @@ namespace MileageTraker.Web.Membership
user.LastActivityDate = DateTime.UtcNow;
context.SaveChanges();
}
return new MembershipUser(System.Web.Security.Membership.Provider.Name, user.Username, user.UserId, user.Email,
null, null,
user.IsApproved, user.IsLockedOut, user.CreateDate.Value, user.LastLoginDate.Value,
user.LastActivityDate.Value, user.LastPasswordChangedDate.Value,
user.LastLockoutDate.Value);
return user.CloneToMembershipUser(System.Web.Security.Membership.Provider.Name);
}
}
@@ -265,7 +253,7 @@ namespace MileageTraker.Web.Membership
}
using (var context = new MileageTrakerContext())
{
User user = context.Users.FirstOrDefault(Usr => Usr.Username == username);
User user = context.Users.FirstOrDefault(usr => usr.Username == username);
if (user == null)
{
return false;
@@ -309,7 +297,7 @@ namespace MileageTraker.Web.Membership
{
using (var context = new MileageTrakerContext())
{
var user = context.Users.FirstOrDefault(Usr => Usr.Username == userName);
var user = context.Users.FirstOrDefault(usr => usr.Username == userName);
if (user != null)
{
user.IsLockedOut = false;
@@ -325,7 +313,9 @@ namespace MileageTraker.Web.Membership
{
var dateActive =
DateTime.UtcNow.Subtract(
TimeSpan.FromMinutes(Convert.ToDouble(System.Web.Security.Membership.UserIsOnlineTimeWindow)));
TimeSpan.FromMinutes(
Convert.ToDouble(
System.Web.Security.Membership.UserIsOnlineTimeWindow)));
using (var context = new MileageTrakerContext())
{
return context.Users.Count(usr => usr.LastActivityDate > dateActive);
@@ -338,13 +328,13 @@ namespace MileageTraker.Web.Membership
{
return false;
}
using (var Context = new MileageTrakerContext())
using (var context = new MileageTrakerContext())
{
var user = Context.Users.FirstOrDefault(Usr => Usr.Username == username);
var user = context.Users.FirstOrDefault(usr => usr.Username == username);
if (user != null)
{
Context.Users.Remove(user);
Context.SaveChanges();
context.Users.Remove(user);
context.SaveChanges();
return true;
}
return false;
@@ -378,11 +368,8 @@ namespace MileageTraker.Web.Membership
.Take(pageSize);
foreach (var user in users)
{
membershipUsers.Add(new MembershipUser(System.Web.Security.Membership.Provider.Name, user.Username, user.UserId,
user.Email, null, null,
user.IsApproved, user.IsLockedOut, user.CreateDate.Value,
user.LastLoginDate.Value, user.LastActivityDate.Value,
user.LastPasswordChangedDate.Value, user.LastLockoutDate.Value));
membershipUsers.Add(
user.CloneToMembershipUser(System.Web.Security.Membership.Provider.Name));
}
}
return membershipUsers;
@@ -402,11 +389,7 @@ namespace MileageTraker.Web.Membership
.Take(pageSize);
foreach (var user in users)
{
membershipUsers.Add(new MembershipUser(System.Web.Security.Membership.Provider.Name, user.Username, user.UserId,
user.Email, null, null,
user.IsApproved, user.IsLockedOut, user.CreateDate.Value,
user.LastLoginDate.Value, user.LastActivityDate.Value,
user.LastPasswordChangedDate.Value, user.LastLockoutDate.Value));
membershipUsers.Add(user.CloneToMembershipUser(System.Web.Security.Membership.Provider.Name));
}
}
return membershipUsers;
@@ -414,21 +397,22 @@ namespace MileageTraker.Web.Membership
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
{
var MembershipUsers = new MembershipUserCollection();
using (var Context = new MileageTrakerContext())
var membershipUsers = new MembershipUserCollection();
using (var context = new MileageTrakerContext())
{
totalRecords = Context.Users.Count();
var Users = Context.Users.OrderBy(Usrn => Usrn.Username).Skip(pageIndex*pageSize).Take(pageSize);
foreach (var user in Users)
totalRecords = context.Users.Count();
var users =
context.Users
.OrderBy(usrn => usrn.Username)
.Skip(pageIndex*pageSize)
.Take(pageSize);
foreach (var user in users)
{
MembershipUsers.Add(new MembershipUser(System.Web.Security.Membership.Provider.Name, user.Username, user.UserId,
user.Email, null, null,
user.IsApproved, user.IsLockedOut, user.CreateDate.Value,
user.LastLoginDate.Value, user.LastActivityDate.Value,
user.LastPasswordChangedDate.Value, user.LastLockoutDate.Value));
membershipUsers.Add(user.CloneToMembershipUser(System.Web.Security.Membership.Provider.Name));
}
}
return MembershipUsers;
return membershipUsers;
}
public string CreateAccount(string userName, string password, bool requireConfirmationToken)
@@ -451,7 +435,7 @@ namespace MileageTraker.Web.Membership
using (var context = new MileageTrakerContext())
{
if (context.Users.Any(Usr => Usr.Username == userName))
if (context.Users.Any(usr => usr.Username == userName))
{
throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateUserName);
}
@@ -462,7 +446,7 @@ namespace MileageTraker.Web.Membership
token = GenerateToken();
}
var NewUser = new User
var newUser = new User
{
UserId = Guid.NewGuid(),
Username = userName,
@@ -474,13 +458,13 @@ namespace MileageTraker.Web.Membership
PasswordFailuresSinceLastSuccess = 0,
LastLoginDate = DateTime.UtcNow,
LastActivityDate = DateTime.UtcNow,
LastLockoutDate = DateTime.UtcNow,
LastLockoutDate = SqlDateTime.MinValue.Value,
IsLockedOut = false,
LastPasswordFailureDate = DateTime.UtcNow,
LastPasswordFailureDate = SqlDateTime.MinValue.Value,
ConfirmationToken = token
};
context.Users.Add(NewUser);
context.Users.Add(newUser);
context.SaveChanges();
return token;
}
@@ -494,7 +478,7 @@ namespace MileageTraker.Web.Membership
}
}
internal static string GenerateToken(RandomNumberGenerator generator)
private static string GenerateToken(RandomNumberGenerator generator)
{
var tokenBytes = new byte[TokenSizeInBytes];
generator.GetBytes(tokenBytes);
+7 -3
View File
@@ -11,7 +11,11 @@ namespace MileageTraker.Web.Membership
public override string ApplicationName
{
get { return GetType().Assembly.GetName().Name; }
set { ApplicationName = GetType().Assembly.GetName().Name; }
set
{
if (value == null) throw new ArgumentNullException("value");
ApplicationName = GetType().Assembly.GetName().Name;
}
}
public override bool RoleExists(string roleName)
@@ -86,7 +90,7 @@ namespace MileageTraker.Web.Membership
}
using (var context = new MileageTrakerContext())
{
User user = context.Users.FirstOrDefault(Usr => Usr.Username == username);
var user = context.Users.FirstOrDefault(usr => usr.Username == username);
if (user != null)
{
return user.Roles.Select(rl => rl.RoleName).ToArray();
@@ -122,7 +126,7 @@ namespace MileageTraker.Web.Membership
{
using (var context = new MileageTrakerContext())
{
Role role = context.Roles.FirstOrDefault(rl => rl.RoleName == roleName);
var role = context.Roles.FirstOrDefault(rl => rl.RoleName == roleName);
if (role == null)
{
var newRole = new Role
+8 -9
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Web;
using System.Web.Routing;
using System.Web.Security;
using MileageTraker.Web.Context;
@@ -47,7 +46,7 @@ namespace MileageTraker.Web.Membership
{
using (var context = new MileageTrakerContext())
{
var user = context.Users.FirstOrDefault(usr => usr.Username == username);
var user = context.Users.First(usr => usr.Username == username);
user.FirstName = firstName;
user.LastName = lastName;
context.SaveChanges();
@@ -134,18 +133,18 @@ namespace MileageTraker.Web.Membership
return CreateUserAndAccount(userName, password, values, requireConfirmationToken: false);
}
public static string CreateUserAndAccount(string userName, string password, object propertyValues = null,
private static string CreateUserAndAccount(string userName, string password, object propertyValues = null,
bool requireConfirmationToken = false)
{
var codeFirstMembership = System.Web.Security.Membership.Provider as CodeFirstMembershipProvider;
IDictionary<string, object> values = null;
if (propertyValues != null)
{
values = new RouteValueDictionary(propertyValues);
}
//IDictionary<string, object> values = null;
//if (propertyValues != null)
//{
// values = new RouteValueDictionary(propertyValues);
//}
return codeFirstMembership.CreateUserAndAccount(userName, password, requireConfirmationToken, values);
return codeFirstMembership.CreateUserAndAccount(userName, password, requireConfirmationToken);
}
public static List<MembershipUser> FindUsersByEmail(string email, int pageIndex, int pageSize)
@@ -97,14 +97,14 @@ namespace MileageTraker.Web.Migrations
,NULL
,1
,0
,NULL
,NULL
,NULL
,'1753-1-1'
,GETDATE()
,'1753-1-1'
,NULL
,NULL
,GETDATE()
,0
,NULL
,GETDATE()
,NULL
,NULL)");
+10
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Security;
namespace MileageTraker.Web.Models
{
@@ -37,5 +38,14 @@ namespace MileageTraker.Web.Models
public virtual DateTime? PasswordVerificationTokenExpirationDate { get; set; }
public virtual ICollection<Role> Roles { get; set; }
public MembershipUser CloneToMembershipUser(string providerName)
{
return new MembershipUser(providerName, Username, UserId,
Email, null, null,
IsApproved, IsLockedOut, CreateDate.Value,
LastLoginDate.Value, LastActivityDate.Value,
LastPasswordChangedDate.Value, LastLockoutDate.Value);
}
}
}
+3
View File
@@ -139,6 +139,9 @@ $(function () {
$("a:contains('" + text + "')")
.prepend('<i class="icon-' + icon + '" /> ');
});
$(".navbar-inverse a[title='Manage']")
.prepend('<i class="icon-user icon-white" /> ');
});
$(function() {
@@ -0,0 +1,24 @@
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace MileageTraker.Web.ViewModels.Account
{
public class ChangePasswordViewModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}
+21
View File
@@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using MileageTraker.Web.Utility;
namespace MileageTraker.Web.ViewModels.Account
{
public class LoginViewModel
{
[Required]
[Display(Name = "Email Address")]
public string EmailAddress { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Display(Name = "Remember me?")]
[NoEditLabel]
public bool RememberMe { get; set; }
}
}
+23
View File
@@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace MileageTraker.Web.ViewModels.Account
{
public class RegisterModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}
-57
View File
@@ -1,57 +0,0 @@
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace MileageTraker.Web.ViewModels
{
public class ChangePasswordViewModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
public class LoginViewModel
{
[Required]
[Display(Name = "Email Address")]
public string EmailAddress { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
public class RegisterModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}
@@ -3,7 +3,7 @@ using AutoMapper;
using MileageTraker.Web.DAL;
using MileageTraker.Web.Utility;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.CreateLog
{
public class ConfirmCreateLogViewModel : CreateLogViewModel
{
@@ -7,7 +7,7 @@ using MileageTraker.Web.DAL;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.CreateLog
{
public class CreateLogViewModel : IValidatableObject
{
@@ -66,8 +66,8 @@ namespace MileageTraker.Web.ViewModels
Mapper.CreateMap<string, int>().ConvertUsing(Convert.ToInt32);
Mapper.CreateMap<string, double>().ConvertUsing(Convert.ToDouble);
Mapper.CreateMap<string, DateTime>().ConvertUsing(new DateTimeTypeConverter());
Mapper.CreateMap<CreateLogViewModel, Log>();
Mapper.CreateMap<Log, CreateLogViewModel>()
Mapper.CreateMap<CreateLogViewModel, Models.Log>();
Mapper.CreateMap<Models.Log, CreateLogViewModel>()
.ForMember(vm => vm.Date, opt => opt.MapFrom(m => m.Date.ToString("d")));
}
@@ -75,14 +75,14 @@ namespace MileageTraker.Web.ViewModels
{
}
public CreateLogViewModel(Log log)
public CreateLogViewModel(Models.Log log)
{
Mapper.Map(log, this);
}
public Log GetLog()
public Models.Log GetLog()
{
var log = new Log();
var log = new Models.Log();
Mapper.Map(this, log);
return log;
}
+1 -2
View File
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MileageTraker.Web.Models;
namespace MileageTraker.Web.ViewModels
{
@@ -10,7 +9,7 @@ namespace MileageTraker.Web.ViewModels
public string EmployeeName { get; set; }
public int Miles { get; set; }
public double GasPurchased { get; set; }
public IEnumerable<Tuple<Log, Log>> LogPairs { get; set; }
public IEnumerable<Tuple<Models.Log, Models.Log>> LogPairs { get; set; }
public int TripCount { get { return LogPairs.Count(); } }
}
}
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using MileageTraker.Web.ViewModels.Log;
namespace MileageTraker.Web.ViewModels
{
@@ -2,7 +2,7 @@ using System;
using AutoMapper;
using MileageTraker.Web.Models;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.Log
{
public class LogIndexViewModel
{
@@ -29,10 +29,10 @@ namespace MileageTraker.Web.ViewModels
static LogIndexViewModel()
{
Mapper.CreateMap<Log, LogIndexViewModel>();
Mapper.CreateMap<Models.Log, LogIndexViewModel>();
}
public LogIndexViewModel(Log log, Log previousLog)
public LogIndexViewModel(Models.Log log, Models.Log previousLog)
{
Mapper.Map(log, this);
if (previousLog != null)
@@ -4,7 +4,7 @@ using System.Web.Mvc;
using AutoMapper;
using MileageTraker.Web.Models;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.Log
{
public class LogPartialDetails
{
@@ -33,13 +33,13 @@ namespace MileageTraker.Web.ViewModels
static LogPartialDetails()
{
Mapper.CreateMap<Log, LogPartialDetails>();
Mapper.CreateMap<Models.Log, LogPartialDetails>();
}
public LogPartialDetails()
{}
public LogPartialDetails(Log log)
public LogPartialDetails(Models.Log log)
{
Mapper.Map(log, this);
}
@@ -1,6 +1,6 @@
using MileageTraker.Web.Models;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.Log
{
public class LogQueryViewModel
{
@@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.Log
{
public class LogResultsViewModel
{
@@ -1,9 +1,8 @@
using System;
using System.Linq;
using System.Collections.Generic;
using MileageTraker.Web.Models;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.Vehicle
{
public class VehicleMileageItem
{
@@ -11,7 +10,7 @@ namespace MileageTraker.Web.ViewModels
public int Miles { get; set; }
public double GasPurchased { get; set; }
public string Prog { get; set; }
public IEnumerable<Tuple<Log, Log>> LogPairs { get; set; }
public IEnumerable<Tuple<Models.Log, Models.Log>> LogPairs { get; set; }
public int TripCount { get { return LogPairs.Count(); } }
}
}
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using MileageTraker.Web.ViewModels.Log;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.Vehicle
{
public class VehicleMileageViewModel
{
@@ -1,9 +1,7 @@
using System.ComponentModel.DataAnnotations;
using AutoMapper;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
namespace MileageTraker.Web.ViewModels
namespace MileageTraker.Web.ViewModels.Vehicle
{
public class VehiclePartialDetails
{
@@ -33,13 +31,13 @@ namespace MileageTraker.Web.ViewModels
static VehiclePartialDetails()
{
Mapper.CreateMap<Vehicle, VehiclePartialDetails>();
Mapper.CreateMap<Models.Vehicle, VehiclePartialDetails>();
}
public VehiclePartialDetails()
{}
public VehiclePartialDetails(Vehicle vehicle)
public VehiclePartialDetails(Models.Vehicle vehicle)
{
Mapper.Map(vehicle, this);
}
+14 -11
View File
@@ -1,4 +1,4 @@
@model MileageTraker.Web.ViewModels.LoginViewModel
@model MileageTraker.Web.ViewModels.Account.LoginViewModel
@{
ViewBag.Title = "Log in";
@@ -9,20 +9,23 @@
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
}
@section Styles
{
<link href="@Url.Content("~/Content/Account.Login.css")" rel="stylesheet" type="text/css" />
}
<h2>@ViewBag.Title</h2>
@using (Html.BeginForm("Login", "Account", new { ViewBag.ReturnUrl }, FormMethod.Post)) {
@using (Html.BeginForm("Login", "Account", new { ViewBag.ReturnUrl }, FormMethod.Post, new {@class = "form-login"})) {
<div class="header"></div>
<h2>@ViewBag.Title</h2>
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@Html.Partial("_ValidationSummary")
<fieldset>
<legend />
<legend></legend>
@Html.EditorForModel()
<div class="control-group">
<div class="controls">
<input type="submit" value="Log in" class="btn btn-primary" />
</div>
</div>
<input type="submit" value="Log in" class="btn btn-primary" />
</fieldset>
}
+7 -4
View File
@@ -1,11 +1,14 @@
@model MileageTraker.Web.ViewModels.ChangePasswordViewModel
@model MileageTraker.Web.ViewModels.Account.ChangePasswordViewModel
@{
ViewBag.Title = "Manage Account";
}
@section Scripts
{
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
}
<hgroup class="title">
<h1>@ViewBag.Title</h1>
</hgroup>
<h2>@ViewBag.Title</h2>
<p class="label label-success">@ViewBag.StatusMessage</p>
+2 -2
View File
@@ -1,4 +1,4 @@
@model MileageTraker.Web.ViewModels.RegisterModel
@model MileageTraker.Web.ViewModels.Account.RegisterModel
@{
ViewBag.Title = "Register";
}
@@ -10,7 +10,7 @@
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary()
@Html.Partial("_ValidationSummary")
<fieldset>
<legend>Registration Form</legend>
@@ -1,27 +1,13 @@
@model MileageTraker.Web.ViewModels.ChangePasswordViewModel
@model MileageTraker.Web.ViewModels.Account.ChangePasswordViewModel
<h3>Change password</h3>
@using (Html.BeginForm("Manage", "Account")) {
@Html.Partial("_ValidationSummary")
@Html.AntiForgeryToken()
@Html.ValidationSummary()
<fieldset>
<legend>Change Password Form</legend>
<ol>
<li>
@Html.LabelFor(m => m.OldPassword)
@Html.PasswordFor(m => m.OldPassword)
</li>
<li>
@Html.LabelFor(m => m.NewPassword)
@Html.PasswordFor(m => m.NewPassword)
</li>
<li>
@Html.LabelFor(m => m.ConfirmPassword)
@Html.PasswordFor(m => m.ConfirmPassword)
</li>
</ol>
<input type="submit" value="Change password" />
<legend></legend>
@Html.EditorForModel()
<input type="submit" value="Change password" class="btn btn-primary" />
</fieldset>
}
@@ -1,25 +0,0 @@
@model MileageTraker.Web.ViewModels.ChangePasswordViewModel
<p>
You do not have a password for this site.
</p>
@using (Html.BeginForm("Manage", "Account")) {
@Html.AntiForgeryToken()
@Html.ValidationSummary()
<fieldset>
<legend>Set Password Form</legend>
<ol>
<li>
@Html.LabelFor(m => m.NewPassword)
@Html.PasswordFor(m => m.NewPassword)
</li>
<li>
@Html.LabelFor(m => m.ConfirmPassword)
@Html.PasswordFor(m => m.ConfirmPassword)
</li>
</ol>
<input type="submit" value="Set password" />
</fieldset>
}
+1 -1
View File
@@ -1,4 +1,4 @@
@model MileageTraker.Web.ViewModels.ConfirmCreateLogViewModel
@model MileageTraker.Web.ViewModels.CreateLog.ConfirmCreateLogViewModel
@{
ViewBag.Title = "Confirm";
+2 -2
View File
@@ -1,4 +1,4 @@
@model MileageTraker.Web.ViewModels.CreateLogViewModel
@model MileageTraker.Web.ViewModels.CreateLog.CreateLogViewModel
@{
ViewBag.Title = "Enter Mileage Log";
@@ -19,7 +19,7 @@
{
<fieldset>
<legend>@ViewBag.Title</legend>
@Html.ValidationSummary(true)
@Html.Partial("_ValidationSummary")
@Html.EditorForModel()
<div class="control-group">
<div class="controls">
+1 -1
View File
@@ -1,4 +1,4 @@
@model MileageTraker.Web.ViewModels.CreateLogViewModel
@model MileageTraker.Web.ViewModels.CreateLog.CreateLogViewModel
@{
ViewBag.Title = "Success";
+2 -2
View File
@@ -19,9 +19,9 @@
<h2>@ViewBag.Title</h2>
@using (Html.BeginForm("Create", "Log", FormMethod.Post, new { @class = "form-horizontal" })) {
@Html.ValidationSummary(true)
@Html.Partial("_ValidationSummary")
<fieldset>
<legend>Log</legend>
<legend></legend>
@Html.EditorForModel()
<div class="control-group">
<div class="controls">
+1 -2
View File
@@ -1,5 +1,4 @@
@using MileageTraker.Web.ViewModels
@model LogPartialDetails
@model MileageTraker.Web.ViewModels.Log.LogPartialDetails
@{
Layout = null;
}
+2 -2
View File
@@ -20,9 +20,9 @@
@using (Html.BeginForm("Edit", "Log", FormMethod.Post, new { @class = "form-horizontal" }))
{
@Html.ValidationSummary(true)
@Html.Partial("_ValidationSummary")
<fieldset>
<legend />
<legend></legend>
@Html.EditorForModel()
+1 -1
View File
@@ -1,6 +1,6 @@
@using MileageTraker.Web.Utility
@using MileageTraker.Web.ViewModels
@model LogResultsViewModel
@model MileageTraker.Web.ViewModels.Log.LogResultsViewModel
@{
ViewBag.Title = "Logs";
+1 -1
View File
@@ -1,4 +1,4 @@
@model MileageTraker.Web.ViewModels.VehicleMileageViewModel
@model MileageTraker.Web.ViewModels.Vehicle.VehicleMileageViewModel
@{
ViewBag.Title = "Vehicle Mileage Report";
}
@@ -1,4 +1,7 @@
<label class="checkbox">
@{
Layout = "~/Views/Shared/EditorTemplates/_FieldLayout.cshtml";
}
<label class="checkbox">
@Html.CheckBox("", ViewData.TemplateInfo.FormattedModelValue)
@Html.LabelForModel()
</label>
@@ -1,6 +1,6 @@
@using MileageTraker.Web.Models
@using MileageTraker.Web.Utility
@model MileageTraker.Web.ViewModels.LogResultsViewModel
@model MileageTraker.Web.ViewModels.Log.LogResultsViewModel
@Html.DropDownList("Year", new SelectList(Model.Years, Model.SelectedYear), new { @class = "input-small" })
@Html.DropDownList("Month", new SelectList(Model.Months, Model.SelectedMonth), new { @class = "input-mini" })
+1 -1
View File
@@ -18,7 +18,7 @@
<li>@Html.ActionLink("Enter Mileage Log", "Index", "CreateLog")</li>
</ul>
<section id="account-management">
@Html.Partial("_Layout.authentication.cshtml")
@Html.Partial("_Layout.authentication")
</section>
</div>
</div>
@@ -6,7 +6,7 @@
<li>
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "form-logout" })) {
@Html.AntiForgeryToken()
<button type="submit" class="btn-link">
<button type="submit" class="btn-link logoff">
Log Off
</button>
}
-1
View File
@@ -10,7 +10,6 @@
</head>
<body>
<div class="container-fluid">
@RenderBody()
</div>
@@ -0,0 +1,7 @@
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Any())
{
<div class="alert alert-error">
<a class="close" data-dismiss="alert">×</a>
@Html.ValidationSummary(true)
</div>
}
+2 -1
View File
@@ -20,8 +20,9 @@
@using (Html.BeginForm("Create", "Vehicle", FormMethod.Post, new { @class = "form-horizontal" }))
{
@Html.ValidationSummary(true)
@Html.Partial("_ValidationSummary")
<fieldset>
<label></label>
@Html.EditorForModel()
<div class="control-group">
+1 -1
View File
@@ -1,4 +1,4 @@
@model MileageTraker.Web.ViewModels.VehiclePartialDetails
@model MileageTraker.Web.ViewModels.Vehicle.VehiclePartialDetails
@{
Layout = null;
}
+2 -2
View File
@@ -20,9 +20,9 @@
@using (Html.BeginForm("Edit", "Vehicle", FormMethod.Post, new { @class = "form-horizontal" }))
{
@Html.ValidationSummary(true)
@Html.Partial("_ValidationSummary")
<fieldset>
<label></label>
@Html.EditorForModel()
<div class="control-group">
<div class="controls">
+16 -12
View File
@@ -133,14 +133,16 @@
<Compile Include="Models\User.cs" />
<Compile Include="Utility\ActionLogAttribute.cs" />
<Compile Include="Utility\HttpParamActionAttribute.cs" />
<Compile Include="ViewModels\AccountModels.cs" />
<Compile Include="ViewModels\Account\ChangePasswordViewModel.cs" />
<Compile Include="ViewModels\Account\LoginViewModel.cs" />
<Compile Include="ViewModels\Account\RegisterModel.cs" />
<Compile Include="ViewModels\EmployeeMileageItem.cs" />
<Compile Include="ViewModels\EmployeeMileageViewModel.cs" />
<Compile Include="ViewModels\LogIndexViewModel.cs" />
<Compile Include="ViewModels\LogPartialDetails.cs" />
<Compile Include="ViewModels\VehicleMileageViewModel.cs" />
<Compile Include="ViewModels\VehiclePartialDetails.cs" />
<Compile Include="ViewModels\VehicleMileageItem.cs" />
<Compile Include="ViewModels\Log\LogIndexViewModel.cs" />
<Compile Include="ViewModels\Log\LogPartialDetails.cs" />
<Compile Include="ViewModels\Vehicle\VehicleMileageViewModel.cs" />
<Compile Include="ViewModels\Vehicle\VehiclePartialDetails.cs" />
<Compile Include="ViewModels\Vehicle\VehicleMileageItem.cs" />
<Compile Include="Utility\FormatHintAttribute.cs" />
<Compile Include="DAL\ChronologicalOrderException.cs" />
<Compile Include="DAL\DataService.cs" />
@@ -162,14 +164,15 @@
<Compile Include="Utility\Algorithms.cs" />
<Compile Include="Utility\ExcelWriter.cs" />
<Compile Include="Utility\TitleCaseFormatter.cs" />
<Compile Include="ViewModels\ConfirmCreateLogViewModel.cs" />
<Compile Include="ViewModels\CreateLogViewModel.cs" />
<Compile Include="ViewModels\CreateLog\ConfirmCreateLogViewModel.cs" />
<Compile Include="ViewModels\CreateLog\CreateLogViewModel.cs" />
<Compile Include="Utility\DenyFutureDateAttribute.cs" />
<Compile Include="Utility\DenyPreviousMonthDateAttribute.cs" />
<Compile Include="ViewModels\LogQueryViewModel.cs" />
<Compile Include="ViewModels\LogResultsViewModel.cs" />
<Compile Include="ViewModels\Log\LogQueryViewModel.cs" />
<Compile Include="ViewModels\Log\LogResultsViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\Account.Login.css" />
<Content Include="Content\bootstrap-responsive.css" />
<Content Include="Content\bootstrap-responsive.min.css" />
<Content Include="Content\bootstrap.css" />
@@ -181,6 +184,7 @@
<Content Include="Content\images\glyphicons_005_car_half.png" />
<Content Include="Content\images\glyphicons_005_car_half_white.png" />
<Content Include="Content\images\glyphicons_026_road.png" />
<Content Include="Content\images\Header.login.png" />
<Content Include="Content\images\Header.png" />
<Content Include="Content\jquery.qtip.min.css" />
<Content Include="Content\images\Rainbow.png" />
@@ -248,11 +252,11 @@
<Content Include="Views\Account\Manage.cshtml" />
<Content Include="Views\Account\Register.cshtml" />
<Content Include="Views\Account\_ChangePasswordPartial.cshtml" />
<Content Include="Views\Account\_SetPasswordPartial.cshtml" />
<Content Include="Views\Shared\EditorTemplates\Password.cshtml" />
<Content Include="Views\Shared\EditorTemplates\Boolean.cshtml" />
<Content Include="Views\Shared\_Layout.login.cshtml" />
<Content Include="Views\Shared\_Layout.authentication.cshtml.cshtml" />
<Content Include="Views\Shared\_Layout.authentication.cshtml" />
<Content Include="Views\Shared\_ValidationSummary.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />