public int CreateAdvert(CreateAdvertViewModel createAdvert) { var advertToSave = Mapper.Map <Advert>(createAdvert); advertToSave.AdvertType = _advertTypeRepository.GetSet().Single(x => x.Mask == createAdvert.AdvertType.Mask); var advert = _genericRepository.Add(advertToSave); var savedPhotos = _findPhotosByIdService.Find(createAdvert.PhotosToSave); _photoService.AddAdvertToPhotos(advert.Id, savedPhotos); return(advert.Id); }