예제 #1
0
        public async Task AddAsync(RealEstateViewModel realEstateViewModel, string userName)
        {
            var user = await _userManager.FindByNameAsync(userName);

            var realEstate = RealEstateMapper.ToModel(realEstateViewModel);

            realEstate.WhenPublished = DateTime.Now;
            realEstate.User          = user;
            await _realEstateRepository.AddAsync(realEstate);
        }
예제 #2
0
        public async Task <IEnumerable <RealEstateViewModel> > GetRealEstatesWithPaginationAsync(RealEstateSearchModel realEstateSearchModel, int page, int numberOfRealEstatesPerPage, string userName)
        {
            var listOfRealEstateViewModels = new List <RealEstateViewModel>();
            var user = await _userManager.FindByNameAsync(userName);

            var list = await _realEstateRepository.GetRealEstatesByConditionWithPaginationAsync(realEstateSearchModel, page, numberOfRealEstatesPerPage, user);

            foreach (var realEstate in list)
            {
                var realEstateViewModel = RealEstateMapper.ToViewModel(realEstate);
                listOfRealEstateViewModels.Add(realEstateViewModel);
            }
            return(listOfRealEstateViewModels);
        }