Add Fuel Log details
This commit is contained in:
@@ -6,6 +6,8 @@ using MileageTraker.Web.Attributes;
|
||||
using MileageTraker.Web.DAL;
|
||||
using MileageTraker.Web.Utility;
|
||||
using MileageTraker.Web.ViewModels.FuelLog;
|
||||
using MileageTraker.Web.ViewModels.Log;
|
||||
using ImportUploadViewModel = MileageTraker.Web.ViewModels.FuelLog.ImportUploadViewModel;
|
||||
|
||||
namespace MileageTraker.Web.Controllers
|
||||
{
|
||||
@@ -46,6 +48,13 @@ namespace MileageTraker.Web.Controllers
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
public ViewResult Details(int id)
|
||||
{
|
||||
var fuelLog = DataService.GetFuelLog(id);
|
||||
var vm = new FuelLogViewModel(fuelLog);
|
||||
return View(vm);
|
||||
}
|
||||
|
||||
#region Import
|
||||
|
||||
public ActionResult ImportUpload()
|
||||
|
||||
@@ -226,12 +226,12 @@ namespace MileageTraker.Web.Controllers
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public PartialViewResult DetailsPartial(int id)
|
||||
public PartialViewResult DetailsPrevious(int id)
|
||||
{
|
||||
var log = DataService.GetLog(id);
|
||||
return PartialView(new LogPartialDetails(log));
|
||||
}
|
||||
|
||||
|
||||
#region Import
|
||||
|
||||
public ActionResult ImportUpload()
|
||||
|
||||
@@ -614,7 +614,7 @@ namespace MileageTraker.Web.DAL
|
||||
|
||||
#endregion
|
||||
|
||||
#region FuelLog
|
||||
#region FuelLog
|
||||
|
||||
public void AddFuelLog(FuelLog fuelLog)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
using AutoMapper;
|
||||
|
||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||
{
|
||||
public class FuelLogViewModel
|
||||
{
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public int FuelLogId { get; set; }
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.Date)]
|
||||
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(128)]
|
||||
[Display(Name = "Driver Name")]
|
||||
public string DriverFullName { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Tag#")]
|
||||
public string TagNumber { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Odometer { get; set; }
|
||||
|
||||
[StringLength(64)]
|
||||
[Display(Name = "City Name")]
|
||||
public string CityName { get; set; }
|
||||
|
||||
[Display(Name = "MPG")]
|
||||
public double MPG { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Gas Purchased")]
|
||||
public double GasPurchased { get; set; }
|
||||
|
||||
[Required]
|
||||
[Display(Name = "Total Price")]
|
||||
public decimal TotalPrice { get; set; }
|
||||
|
||||
// Matched log
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public int? LogId { get; set; }
|
||||
|
||||
static FuelLogViewModel()
|
||||
{
|
||||
Mapper.CreateMap<FuelLogViewModel, Models.FuelLog>();
|
||||
Mapper.CreateMap<Models.FuelLog, FuelLogViewModel>()
|
||||
.ForMember(dest => dest.LogId,
|
||||
opt => opt.ResolveUsing(
|
||||
fl => fl.Log != null ? (int?)fl.Log.LogId : null
|
||||
));
|
||||
}
|
||||
|
||||
public FuelLogViewModel(Models.FuelLog fuelLog)
|
||||
{
|
||||
Mapper.Map(fuelLog, this);
|
||||
}
|
||||
|
||||
public FuelLogViewModel()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
@model MileageTraker.Web.ViewModels.FuelLog.FuelLogViewModel
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Fuel Log Details";
|
||||
}
|
||||
|
||||
@Html.Partial("_StatusMessage")
|
||||
|
||||
<h2 class="center-content">@ViewBag.Title</h2>
|
||||
|
||||
<div class="center-content well">
|
||||
@Html.DisplayForModel()
|
||||
</div>
|
||||
|
||||
<div class="center-content btn-toolbar">
|
||||
@if (Model.LogId != null)
|
||||
{
|
||||
@Html.ActionLink("View Mileage Log", "Details", "Log", new {id = Model.LogId}, new {@class = "btn"})
|
||||
}
|
||||
</div>
|
||||
@@ -63,7 +63,7 @@
|
||||
if (item.PreviousLogId != null)
|
||||
{
|
||||
string miles = (item.Miles).ToString();
|
||||
return Html.ActionLink(miles, "DetailsPartial", new { id = item.PreviousLogId }, new { @class = "qtip-modal" });
|
||||
return Html.ActionLink(miles, "DetailsPrevious", new { id = item.PreviousLogId }, new { @class = "qtip-modal" });
|
||||
}
|
||||
return Html.Raw("<span class='miles-unknown'>?</span>");
|
||||
}),
|
||||
|
||||
+3
-3
@@ -230,6 +230,7 @@
|
||||
<Compile Include="ViewModels\CreateLog\ImportUploadViewModel.cs" />
|
||||
<Compile Include="ViewModels\DriverMileageItem.cs" />
|
||||
<Compile Include="ViewModels\DriverMileageViewModel.cs" />
|
||||
<Compile Include="ViewModels\FuelLog\FuelLogViewModel.cs" />
|
||||
<Compile Include="ViewModels\FuelLog\ImportFuelLogViewModel.cs" />
|
||||
<Compile Include="ViewModels\FuelLog\ImportMatchedLogViewModel.cs" />
|
||||
<Compile Include="ViewModels\FuelLog\ImportUploadViewModel.cs" />
|
||||
@@ -305,6 +306,8 @@
|
||||
<Content Include="Views\FuelLog\Index.cshtml" />
|
||||
<Content Include="Views\FuelLog\ImportMatchedLog.cshtml" />
|
||||
<Content Include="Views\FuelLog\Empty.cshtml" />
|
||||
<Content Include="Views\FuelLog\Details.cshtml" />
|
||||
<Content Include="Views\Log\DetailsPrevious.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Content\Account.Login.css" />
|
||||
@@ -508,9 +511,6 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Shared\DisplayTemplates\DateTime.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Log\DetailsPartial.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Vehicle\DetailsPartial.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user