Exemplo n.º 1
0
        public IActionResult UpdateAdvertisement(Guid adId)
        {
            var ad = _adService.GetAd(adId);

            if (ad.UserId != User.Claims.GetUserId())
            {
                return(RedirectToAction("Index"));
            }

            return(View(ad));
        }
Exemplo n.º 2
0
        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)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> ViewDetailAd(int id)
        {
            var ad = await adService.GetAd(id);

            var model = this.mapper.Map <ViewDetailAdViewModel>(ad);

            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <ActionResult <AdEntity> > GetAdEntity(int id)
        {
            var adEntity = await _adService.GetAd(id, this.HttpContext);

            if (adEntity == null)
            {
                return(NotFound());
            }

            return(Ok(adEntity));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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"));
            }
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 9
0
 public IEnumerable <AdvertisingModel> GetAd(int numberOfAd)
 {
     return(_provider.GetAd(numberOfAd));
 }
Exemplo n.º 10
0
 public IEnumerable <AdvertisingModel> GetAd(int numberOfAd)
 {
     return(_adService.GetAd(numberOfAd));
 }