public IActionResult UpdateAdvertisement(Guid adId) { var ad = _adService.GetAd(adId); if (ad.UserId != User.Claims.GetUserId()) { return(RedirectToAction("Index")); } return(View(ad)); }
public ActionResult PersonalAds(int?page) { int id = User.Identity.GetUserId <int>(); int pageSize = 8; int pageNumber = (page ?? 1); var config = new MapperConfiguration(cfg => { cfg.CreateMap <AdDTO, AdVM>(); cfg.CreateMap <KindDTO, KindVM>(); cfg.CreateMap <CategoryDTO, CategoryVM>(); cfg.CreateMap <LocationDTO, LocationVM>(); cfg.CreateMap <UserDTO, UserVM>() .ForMember("ConfirmPassword", opt => opt.Ignore()); cfg.CreateMap <TagDTO, TagVM>() .ForMember(t => t.InfoReviewTags, p => p.Ignore()); cfg.CreateMap <ImageDTO, ImageVM>(); }); //config.AssertConfigurationIsValid(); var mapper = config.CreateMapper(); var ads = mapper.Map <IEnumerable <AdDTO>, IEnumerable <AdVM> >(adService.GetAd(id)); adService.Dispose(); return(PartialView(ads.ToPagedList(pageNumber, pageSize))); }
public async Task <IActionResult> ViewDetailAd(int id) { var ad = await adService.GetAd(id); var model = this.mapper.Map <ViewDetailAdViewModel>(ad); return(View(model)); }
public async Task <ActionResult <AdEntity> > GetAdEntity(int id) { var adEntity = await _adService.GetAd(id, this.HttpContext); if (adEntity == null) { return(NotFound()); } return(Ok(adEntity)); }
public async Task <ActionResult <CompleteAdDTO> > RepublishAd([FromBody] ModifyAdDTO modifyAdDTO) { string username = modifyAdDTO.Username; string authTokenString = modifyAdDTO.AuthToken; Models.Account accountToFind = await _adService.GetUser(username, authTokenString); if (accountToFind == null) { return(StatusCode(StatusCodes.Status401Unauthorized)); } Ad adToFind = await _adService.GetAd(accountToFind.Id, modifyAdDTO.AdId); if (adToFind == null) { return(StatusCode(StatusCodes.Status401Unauthorized)); } adToFind.DateOfCreation = DateTime.Now; await _smallPostersContext.SaveChangesAsync(); return(StatusCode(StatusCodes.Status200OK)); }
public IActionResult Ad(int id = 0) { var userId = User.GetUserId(); if (!string.IsNullOrWhiteSpace(userId)) { var ad = id == 0 ? new Ad { Id = id, CreatedDate = DateTime.Today, Value = 0, UserId = userId } : _adService.GetAd(id, userId); var vm = new AdViewModel() { Heading = id == 0 ? "Dodawanie nowego ogłoszenia" : "Edycja ogłoszenia", Ad = ad, Categories = _categoryService.GetCategories() }; return(View(vm)); } else { return(RedirectToAction("Ads", "Ad")); } }
public IActionResult EditAd(int id) { var ad = adService.GetAd(id); var model = new EditAdInputModel { Id = ad.Id, Title = ad.Title, Description = ad.Description, RentPrice = ad.RentPrice, BuildingClass = ad.BuildingClass.ToString(), Location = ad.Location, PropertyType = ad.PropertyType.ToString(), Size = ad.Size, }; return(this.View(model)); }
public IActionResult CreateAppointment(AppointmentInputModel model) { if (!ModelState.IsValid) { return(this.View(model)); } if (model.AppointmentDate < DateTime.UtcNow) { return(this.View(model)); } if (model.AppointmentDate > DateTime.UtcNow.AddDays(10)) { return(this.View(model)); } var username = this.User.Identity.Name; var ad = adService.GetAd(model.AdId); var userProfile = profileService.GetUserByUsername(username); var agencyProfile = profileService.GetAgencyById(ad.AgencyProfileId); appointmentService.Create(ad, userProfile, agencyProfile, model.AppointmentDate); return(this.Redirect(GlobalConstants.homeUrl)); }
public IEnumerable <AdvertisingModel> GetAd(int numberOfAd) { return(_provider.GetAd(numberOfAd)); }
public IEnumerable <AdvertisingModel> GetAd(int numberOfAd) { return(_adService.GetAd(numberOfAd)); }