public async Task <IActionResult> EditAd(int id)
        {
            AdViewModel model = new AdViewModel();

            var getAdByIdResult = await _adService.GetAdById(id, dataForEdit : true);

            if (!getAdByIdResult.Succedeed)
            {
                return(View("Details", model));
            }


            var dataForSelectList = _adService.GetDataForCreatingAdOrDataForFilter();

            model = _prepearingModel.PrepearingAdViewModel(
                dataForSelectList.citiesDTO,
                dataForSelectList.cityAreasDTO,
                dataForSelectList.productTypesDTO,
                dataForSelectList.productModelsDTO,
                dataForSelectList.productMemoriesDTO,
                dataForSelectList.productColorsDTO,
                dataForSelectList.productStateDTO,
                getAdByIdResult.Property);

            ViewBag.AdId = id;
            return(View("Details", model));
        }
示例#2
0
        public async Task <ActionResult> Details(int id)
        {
            User user = await _userManager.GetUserAsync(User);

            AdModel model = _adService.GetAdById(id, user.Id);

            return(View(model));
        }
        public async Task <IActionResult> ConversationByAdIdAndContactId(int adId, string contactId)
        {
            ConversationIndexViewModel model = new ConversationIndexViewModel();
            string userId = _userManager.GetUserId(User);

            model.Conversation = await _conversationService.GetConversationByAdIdAndSenderIdAndContactId(adId, userId, contactId);

            ViewBag.SenderId  = userId;
            ViewBag.RecivedId = contactId;
            ViewBag.AdId      = adId;

            var getAdByIdResult = await _adService.GetAdById(adId, dataForEdit : false);

            if (!getAdByIdResult.Succedeed)
            {
                return(View("Conversations", model));
            }

            model.Ad = getAdByIdResult.Property;
            return(View("Conversations", model));
        }
        public async Task <IActionResult> AdDetails(int?id)
        {
            AdDetailsViewModel model = new AdDetailsViewModel();

            var getByIdReult = await _adService.GetAdById(id ?? 0, dataForEdit : false);

            if (!getByIdReult.Succedeed)
            {
                return(View(model));
            }

            await _adViewsService.UpdateViewsAd(id ?? 0);

            model.AddDetails = getByIdReult.Property;

            var similarAdsResult =
                await _adService.GetAdsByProductTypeId(model.AddDetails.Characteristics.ProductType.ProductTypesId);

            if (!similarAdsResult.Succedeed)
            {
                return(View(model));
            }

            var similarAds = similarAdsResult.Property;

            model.SimilarAds = similarAds.OrderBy(x => Guid.NewGuid()).Take(4).ToList();

            var otherAdsByAuthorResult = await _adService.GetAdsByUserId(model.AddDetails.ApplicationUser.Id);

            if (!otherAdsByAuthorResult.Succedeed)
            {
                return(View(model));
            }

            var otherAdsByAuthor = otherAdsByAuthorResult.Property;

            model.OtherAdsByAuthor = otherAdsByAuthor.Take(5).ToList();

            return(View(model));
        }
        public async Task <IActionResult> Index(int id = 0)
        {
            var model = new ServicesIndexViewModel()
            {
                Ad = new AdDTO()
            };

            var operationDetails = await _adService.GetAdById(id, dataForEdit : false);

            if (!operationDetails.Succedeed)
            {
                return(View("Index", model.StatusMessage = operationDetails.Message));
            }

            model.Ad           = operationDetails.Property;
            model.SelectedAdId = id;
            model.Services     = await _servicesService.GetAllServices().ToListAsync();

            model = _prepearingModelHelper.ConfigServicesIndexViewModel(model);

            return(View("Index", model));
        }
 public Ev Get(int id)
 {
     return(_adService.GetAdById(id));
 }