Add service reminder migration Add Completed Service button to vehicle

This commit is contained in:
2015-10-14 22:27:01 -04:00
parent 43d471af94
commit a6fb9d54c6
12 changed files with 246 additions and 0 deletions
@@ -0,0 +1,18 @@
using System.Reflection;
using System.Web.Mvc;
namespace MileageTraker.Web.Attributes
{
public class RequireRequestValueAttribute : ActionMethodSelectorAttribute
{
public RequireRequestValueAttribute(string valueName)
{
ValueName = valueName;
}
public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo)
{
return (controllerContext.HttpContext.Request[ValueName] != null);
}
public string ValueName { get; private set; }
}
}
+1
View File
@@ -14,6 +14,7 @@ namespace MileageTraker.Web.Context
public DbSet<PurposeType> PurposeTypes { get; set; }
public DbSet<FuelLog> FuelLogs { get; set; }
public DbSet<VehicleService> VehicleServices { get; set; }
public DbSet<ServiceReminder> ServiceReminders { get; set; }
/*
* WebSecurity.Register("Demo", "123456", "demo@demo.com", true, "Demo", "Demo");
+1
View File
@@ -37,6 +37,7 @@ namespace MileageTraker.Web.Controllers
[ActionLog]
public ActionResult Export(FuelLogQueryViewModel query)
{
query.Unmatched = false; // override unmatched for export, export them all!
var validLogYearMonths = DataService.GetValidFuelLogMonths();
// default parameter processing
@@ -63,6 +63,12 @@ namespace MileageTraker.Web.Controllers
return View();
}
[RequireRequestValue("vehicleId")]
public ActionResult Create(string vehicleId)
{
return View(new VehicleServiceViewModel{VehicleId = vehicleId});
}
[HttpPost]
[ActionLog]
public ActionResult Create(VehicleServiceViewModel viewModel)
+1
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
@@ -0,0 +1,29 @@
// <auto-generated />
namespace MileageTraker.Web.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")]
public sealed partial class ServiceReminder : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(ServiceReminder));
string IMigrationMetadata.Id
{
get { return "201510150220550_ServiceReminder"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,32 @@
namespace MileageTraker.Web.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class ServiceReminder : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.ServiceReminder",
c => new
{
ServiceReminderId = c.Int(nullable: false, identity: true),
TargetOdometer = c.Int(nullable: false),
Description = c.String(maxLength: 64),
Vehicle_VehicleId = c.String(nullable: false, maxLength: 6),
})
.PrimaryKey(t => t.ServiceReminderId)
.ForeignKey("dbo.Vehicle", t => t.Vehicle_VehicleId, cascadeDelete: true)
.Index(t => t.Vehicle_VehicleId);
}
public override void Down()
{
DropForeignKey("dbo.ServiceReminder", "Vehicle_VehicleId", "dbo.Vehicle");
DropIndex("dbo.ServiceReminder", new[] { "Vehicle_VehicleId" });
DropTable("dbo.ServiceReminder");
}
}
}
File diff suppressed because one or more lines are too long
+20
View File
@@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
using MileageTraker.Web.Attributes;
namespace MileageTraker.Web.Models
{
public class ServiceReminder
{
[Key]
public int ServiceReminderId { get; set; }
[Required]
public virtual Vehicle Vehicle { get; set; }
[InputSize("small")]
public int TargetOdometer { get; set; }
[StringLength(64)]
public string Description { get; set; }
}
}
+2
View File
@@ -88,5 +88,7 @@ namespace MileageTraker.Web.Models
public int? CurrentOdometer { get; set; }
public virtual ICollection<Log> Logs { get; set; }
public virtual ICollection<ServiceReminder> ServiceReminders { get; set; }
}
}
+1
View File
@@ -28,5 +28,6 @@
{
@Html.ActionLink("Reactivate", "SetActive", new {id = Model.VehicleId}, new {@class = "btn"})
}
@Html.ActionLink("Add Completed Service", "Create", "VehicleService", new { VehicleId = Model.VehicleId }, new { @class = "btn" })
@Html.ActionLink("Logs", "Index", "Log", new { Model.VehicleId}, new { @class = "btn" })
</div>
+9
View File
@@ -130,6 +130,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Attributes\ActionLogAttribute.cs" />
<Compile Include="Attributes\RequireRequestValueAttribute.cs" />
<Compile Include="Attributes\CurrencyAttribute.cs" />
<Compile Include="Attributes\DenyFutureDateAttribute.cs" />
<Compile Include="Attributes\DenyPreviousMonthDateAttribute.cs" />
@@ -221,10 +222,15 @@
<Compile Include="Migrations\201510070326593_VehicleService.Designer.cs">
<DependentUpon>201510070326593_VehicleService.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201510150220550_ServiceReminder.cs" />
<Compile Include="Migrations\201510150220550_ServiceReminder.Designer.cs">
<DependentUpon>201510150220550_ServiceReminder.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Models\DomainRules.cs" />
<Compile Include="Models\FuelLog.cs" />
<Compile Include="Models\PurposeType.cs" />
<Compile Include="Models\ServiceReminder.cs" />
<Compile Include="Utility\NameNormalizer.cs" />
<Compile Include="ViewModels\Account\ResetPasswordViewModel.cs" />
<Compile Include="Models\Role.cs" />
@@ -571,6 +577,9 @@
<EmbeddedResource Include="Migrations\201510070326593_VehicleService.resx">
<DependentUpon>201510070326593_VehicleService.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201510150220550_ServiceReminder.resx">
<DependentUpon>201510150220550_ServiceReminder.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>