コード例 #1
0
        private List <VehicleGlassShortResponseModel> FindProductsByVehicleInfo(VehicleGlassRequestModel requestModel)
        {
            var vehicle       = _vehicles.GetVehicleByMakeModelAndBodyTypeIds(requestModel.MakeId, requestModel.ModelId, requestModel.BodyTypeId);
            var glassesResult = new List <VehicleGlassShortResponseModel>();

            var applicableGlasses = !string.IsNullOrEmpty(requestModel.ProductType)
                ? _vehicles.GetApplicableGLassesByProductType(vehicle, requestModel.ProductType)
                : _vehicles.GetApplicableGLasses(vehicle);

            if (applicableGlasses != null)
            {
                User user = null;
                if (User.Identity.IsAuthenticated)
                {
                    user = _users.GetByEmail(User.Identity.Name);
                }

                foreach (var glass in applicableGlasses)
                {
                    var glassToAdd = Mapper.Map <VehicleGlassShortResponseModel>(glass);
                    glassToAdd.ProductInfos = GetProductInfos(glass, user);

                    glassesResult.Add(glassToAdd);
                }
            }

            return(glassesResult);
        }