Add currency attribute
This commit is contained in:
@@ -11,7 +11,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
{
|
{
|
||||||
public ActionResult Index(VehicleServiceQueryViewModel query)
|
public ActionResult Index(VehicleServiceQueryViewModel query)
|
||||||
{
|
{
|
||||||
var vehicleServices = DataService.GetVehicleServices();
|
var vehicleServices = DataService.GetVehicleServices().ToList();
|
||||||
var viewModel = new VehicleServiceResultsViewModel
|
var viewModel = new VehicleServiceResultsViewModel
|
||||||
{
|
{
|
||||||
ServiceItems = vehicleServices.Select(s => new VehicleServiceViewModel(s))
|
ServiceItems = vehicleServices.Select(s => new VehicleServiceViewModel(s))
|
||||||
@@ -19,6 +19,13 @@ namespace MileageTraker.Web.Controllers
|
|||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ViewResult Details(int id)
|
||||||
|
{
|
||||||
|
var vehicleService = DataService.GetVehicleService(id);
|
||||||
|
var viewModel = new VehicleServiceViewModel(vehicleService);
|
||||||
|
return View(viewModel);
|
||||||
|
}
|
||||||
|
|
||||||
public ActionResult Create()
|
public ActionResult Create()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
@@ -32,6 +39,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
{
|
{
|
||||||
var vehicleService = viewModel.GetVehicleService();
|
var vehicleService = viewModel.GetVehicleService();
|
||||||
|
|
||||||
|
|
||||||
vehicleService.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
vehicleService.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
||||||
DataService.AddVehicleService(vehicleService);
|
DataService.AddVehicleService(vehicleService);
|
||||||
|
|
||||||
@@ -43,5 +51,29 @@ namespace MileageTraker.Web.Controllers
|
|||||||
|
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ActionResult Edit(int id)
|
||||||
|
{
|
||||||
|
var vehicleService = DataService.GetVehicleService(id);
|
||||||
|
var viewModel = new VehicleServiceViewModel(vehicleService);
|
||||||
|
return View(viewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[ActionLog]
|
||||||
|
public ActionResult Edit(VehicleServiceViewModel viewModel)
|
||||||
|
{
|
||||||
|
if (ModelState.IsValid)
|
||||||
|
{
|
||||||
|
var vehicleService = viewModel.GetVehicleService();
|
||||||
|
vehicleService.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
||||||
|
|
||||||
|
DataService.UpdateVehicleService(vehicleService);
|
||||||
|
TempData["StatusMessage"] = "Changes saved for vehicle service " + vehicleService.Vehicle.VehicleId;
|
||||||
|
return RedirectToAction("Details", new { id = vehicleService.VehicleServiceId });
|
||||||
|
}
|
||||||
|
return View(viewModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -823,7 +823,7 @@ namespace MileageTraker.Web.DAL
|
|||||||
return vehicleServices;
|
return vehicleServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VehicleService GetVehicleServices(string id)
|
public VehicleService GetVehicleService(int id)
|
||||||
{
|
{
|
||||||
return _db.VehicleServices.Find(id);
|
return _db.VehicleServices.Find(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using MileageTraker.Web.Attributes;
|
||||||
using MileageTraker.Web.ViewModels.Log;
|
using MileageTraker.Web.ViewModels.Log;
|
||||||
|
|
||||||
namespace MileageTraker.Web.ViewModels.FuelLog
|
namespace MileageTraker.Web.ViewModels.FuelLog
|
||||||
@@ -44,6 +45,7 @@ namespace MileageTraker.Web.ViewModels.FuelLog
|
|||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[Display(Name = "Total Price")]
|
[Display(Name = "Total Price")]
|
||||||
|
[Currency]
|
||||||
public decimal TotalPrice { get; set; }
|
public decimal TotalPrice { get; set; }
|
||||||
|
|
||||||
// Matched log
|
// Matched log
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace MileageTraker.Web.ViewModels.VehicleService
|
|||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[InputSize("small")]
|
[InputSize("small")]
|
||||||
[Units("$")]
|
[Currency]
|
||||||
public decimal Price { get; set; }
|
public decimal Price { get; set; }
|
||||||
|
|
||||||
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
|
[StringLength(64, MinimumLength = 3, ErrorMessage = "Minimum 3 characters")]
|
||||||
@@ -45,7 +45,8 @@ namespace MileageTraker.Web.ViewModels.VehicleService
|
|||||||
static VehicleServiceViewModel()
|
static VehicleServiceViewModel()
|
||||||
{
|
{
|
||||||
Mapper.CreateMap<VehicleServiceViewModel, Models.VehicleService>();
|
Mapper.CreateMap<VehicleServiceViewModel, Models.VehicleService>();
|
||||||
Mapper.CreateMap<Models.VehicleService, VehicleServiceViewModel>();
|
Mapper.CreateMap<Models.VehicleService, VehicleServiceViewModel>()
|
||||||
|
.ForMember(dest => dest.VehicleId, opt => opt.MapFrom(src => src.Vehicle.VehicleId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public VehicleServiceViewModel(Models.VehicleService vehicleService)
|
public VehicleServiceViewModel(Models.VehicleService vehicleService)
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Vehicle Service Details" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Html.Partial("_StatusMessage")
|
||||||
|
|
||||||
|
<h2 class="center-content"><i class="fa fa-wrench"></i> @ViewBag.Title</h2>
|
||||||
|
<div class="center-content well">
|
||||||
|
@Html.DisplayForModel()
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="center-content btn-toolbar">
|
||||||
|
@Html.ActionLink("Edit", "Edit", new { id = Model.VehicleServiceId }, new { @class = "btn" })
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Edit Vehicle Service";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Html.Partial("_StatusMessage")
|
||||||
|
|
||||||
|
<h2 class="center-content"><i class="fa fa-wrench"></i> @ViewBag.Title</h2>
|
||||||
|
|
||||||
|
@using (Html.BeginForm("Edit", "VehicleService", FormMethod.Post, new { @class = "form-horizontal well center-content" }))
|
||||||
|
{
|
||||||
|
@Html.Partial("_ValidationSummary")
|
||||||
|
<fieldset>
|
||||||
|
<legend></legend>
|
||||||
|
@Html.EditorForModel()
|
||||||
|
<div class="form-actions">
|
||||||
|
<input type="submit" value="Save" class="btn btn-primary" />
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
}
|
||||||
@@ -130,6 +130,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Attributes\ActionLogAttribute.cs" />
|
<Compile Include="Attributes\ActionLogAttribute.cs" />
|
||||||
|
<Compile Include="Attributes\CurrencyAttribute.cs" />
|
||||||
<Compile Include="Attributes\DenyFutureDateAttribute.cs" />
|
<Compile Include="Attributes\DenyFutureDateAttribute.cs" />
|
||||||
<Compile Include="Attributes\DenyPreviousMonthDateAttribute.cs" />
|
<Compile Include="Attributes\DenyPreviousMonthDateAttribute.cs" />
|
||||||
<Compile Include="Attributes\FormatHintAttribute.cs" />
|
<Compile Include="Attributes\FormatHintAttribute.cs" />
|
||||||
@@ -330,6 +331,8 @@
|
|||||||
<Content Include="Views\Shared\EditorTemplates\FuelLogResultsViewModel.cshtml" />
|
<Content Include="Views\Shared\EditorTemplates\FuelLogResultsViewModel.cshtml" />
|
||||||
<Content Include="Views\VehicleService\Index.cshtml" />
|
<Content Include="Views\VehicleService\Index.cshtml" />
|
||||||
<Content Include="Views\VehicleService\Create.cshtml" />
|
<Content Include="Views\VehicleService\Create.cshtml" />
|
||||||
|
<Content Include="Views\VehicleService\Edit.cshtml" />
|
||||||
|
<Content Include="Views\VehicleService\Details.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Content\Account.Login.css" />
|
<Content Include="Content\Account.Login.css" />
|
||||||
|
|||||||
Reference in New Issue
Block a user