Ejemplo n.º 1
0
        public async Task <IActionResult> Add([FromRoute(Name = "id")] int vehicleId)
        {
            if (!(await this.vehicleService.AllAsync()).Any(v => v.Id == vehicleId))
            {
                return(this.BadRequest());
            }

            var vehicleVignette = await this.vignettesService.DoesVehicleHaveActiveVignetteAsync(vehicleId);

            if (vehicleVignette)// && vehicleVignette.)
            {
                TempData.AddFailureMessage(string.Format(ActiveItem, vehicleId, "vignette"));
                return(this.RedirectToAction <VehiclesController>(c => c.Edit(vehicleId), new { id = vehicleId }));
            }

            return(this.View(new VignetteFormViewModel
            {
                VehicleId = vehicleId,
                StartDate = DateTime.UtcNow,
                EndDate = DateTime.UtcNow
            }));
        }