public async Task <ActionResult> Update(UpdateVehicleRequestModel requestModel)
        {
            var vehicle = await VehicleManager.GetOneOrDefaultAsync <Vehicle>(
                x => x.Id == requestModel.VehicleId);

            // ReSharper disable once InvertIf
            if (vehicle != null)
            {
                var modelYearColor = await VehicleManager.GetOneOrDefaultAsync <ModelYearColor>(
                    x => x.Id == requestModel.ModelYearColorId);

                var color = await VehicleManager.GetOneOrDefaultAsync <Paint>(
                    x => x.Id == requestModel.ColorId);

                if (!(modelYearColor == null || color == null))
                {
                    // Map the request to the domain model. Translate the ModelYear and Color as well.
                    Mapper.Map(requestModel, vehicle
                               , opts => opts.AfterMap((s, d) =>
                    {
                        d.ModelYear = modelYearColor.ModelYear;
                        d.Color     = color;
                    }));

                    VehicleManager.SaveOrUpdateAsync(vehicle).Wait();
                }
            }

            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Add(AddVehicleRequestModel requestModel)
        {
            // Remember this Controller operates from ModelYearColor perspective for starters.
            var modelYearColor = await VehicleManager.GetOneOrDefaultAsync <ModelYearColor>(
                x => x.Id == requestModel.ModelYearColorId);

            var color = await VehicleManager.GetOneOrDefaultAsync <Paint>(
                x => x.Id == requestModel.ColorId);

            // ReSharper disable once InvertIf
            if (!(modelYearColor == null || color == null))
            {
                var vehicle = Mapper.Map(requestModel, new Vehicle {
                    ModelYear = modelYearColor.ModelYear, Color = color
                });
                // Save the mapped Vehicle request.
                VehicleManager.SaveOrUpdateAsync(vehicle).Wait();
            }

            return(RedirectToAction("Index"));
        }