public static CarType Map(CarTypeViewModel model) { return(new CarType() { Id = model.Id, Name = model.Name }); }
CarBrandTableViewModel ICarBrandService.GetCarBrandsTable(CarTypeViewModel model = null) { var brands = CatalogUow.CarBrands.All() .OrderBy(it => it.Name) .Include(it => it.Country) .Include(it => it.CarModels) .ThenInclude(t => t.CarType); if (model != null && model.Id != 0) { var filtered = brands.Where(it => it.CarModels.Any(cm => cm.CarTypeId == model.Id)).ToList(); return(CreateTableViewModel(EntityMapper.Map(filtered), model.Id)); } var filteredBrands = brands.Where(it => it.CarModels.Any()).ToList(); return(CreateTableViewModel(EntityMapper.Map(filteredBrands))); }
public async Task <RequestResultViewModel> UpdateCarTypeAsync(CarTypeViewModel carType) { return(await httpClient.PutJsonAsync <RequestResultViewModel>("api/cartype", carType)); }