public AdvertDetailViewModel GetAd(int id)
        {
            // виж AdvertController -> Detail();
            //throw new NotImplementedException("Impl. GetAd(id)");
            var ad = context.JobAds.Find(id);

            if (ad == null)
            {
                throw new ArgumentException("Cannot find the specified ad.");
            }
            var employer = context.Employers.Find(ad.EmployerId);

            if (employer == null)
            {
                throw new ArgumentException("Cannot find the employer associated with the ad.");
            }
            var detailedAd = new AdvertDetailViewModel()
            {
                CompanyBossFirstName = employer.FirstName,
                CompanyBossLastName  = employer.LastName,
                CompanyName          = employer.CompanyName,
                CompanyLocation      = employer.CurrentAddress,
                Position             = ad.PositionName,
                Description          = ad.Description,
                ContactEmail         = employer.ContactEmail,
                ContactPhone         = employer.ContactPhone
            };

            return(detailedAd);
        }
        /// <summary>
        /// Create Advert object
        /// </summary>
        /// <returns></returns>
        private AdvertViewModel GetAdvert()
        {
            var category = new CategoryViewModel {
                ID = 6, Name = "subcat2", ParentID = 2
            };

            AdPictureViewModel picture1 = new AdPictureViewModel
            {
                ID     = 1,
                Uuid   = "0b83b507-8c11-4c0e-96d2-5fd773d525f7",
                CdnUrl = "https://ucarecdn.com/0b83b507-8c11-4c0e-96d2-5fd773d525f7/",
                Name   = "about me sample 3.PNG",
                Size   = 135083
            };
            AdPictureViewModel picture2 = new AdPictureViewModel
            {
                ID     = 2,
                Uuid   = "c1df9f17-61ad-450a-87f9-d846c312dae0",
                CdnUrl = "https://ucarecdn.com/c1df9f17-61ad-450a-87f9-d846c312dae0/",
                Name   = "about me sample 4.PNG",
                Size   = 146888
            };
            List <AdPictureViewModel> pictures = new List <AdPictureViewModel> {
                picture1, picture2
            };

            AdvertDetailViewModel advertDetail = new AdvertDetailViewModel
            {
                ID         = 8,
                Title      = "Black Toyota for sale",
                Body       = "Black 4x4 Toyota cruiser",
                Email      = "pearl@email",
                GroupCdn   = "GroupCdnValue",
                GroupCount = 2,
                GroupSize  = 2048,
                GroupUuid  = "GroupUuidValue",
                Location   = "Gaborone",
                AdPictures = pictures
            };

            AdvertViewModel advert = new AdvertViewModel
            {
                ID         = 8,
                Status     = EnumTypes.AdvertStatus.SUBMITTED.ToString(),
                CategoryID = 6,
                Detail     = advertDetail,
                Category   = category
            };

            return(advert);
        }
        public async Task <AdvertDetailViewModel> DetalisAdvert(int id)
        {
            var adv = await _context.Adverts.Where(m => m.AdvertId == id).FirstOrDefaultAsync();

            var ads = await _context.Addresses.Where(m => m.AdressId == adv.AddressId).FirstOrDefaultAsync();

            var us = await _context.Users.Where(m => m.Id == adv.UserId).FirstOrDefaultAsync();

            AdvertDetailViewModel item = new AdvertDetailViewModel {
                Advert = adv, Address = ads, User = us
            };


            return(item);
        }
Exemple #4
0
        public AdvertDetailViewModel GetAd(int id)
        {
            // виж AdvertController -> Detail();
            //throw new NotImplementedException("Impl. GetAd(id)");
            var ad = context.JobAds.Find(id);

            if (ad == null)
            {
                throw new ArgumentException("Cannot find the specified ad.");
            }
            var employer = context.Employers.Find(ad.EmployerId);

            if (employer == null)
            {
                throw new ArgumentException("Cannot find the employer associated with the ad.");
            }

            bool loggedIn = false;

            foreach (var adv in context.JobVolunteer.Where(x => x.JobAdId == id))
            {
                if (adv.VolunteerId == CurrentSigned.VolunteerId)
                {
                    loggedIn = true;
                }
            }

            var detailedAd = new AdvertDetailViewModel()
            {
                Id                   = id,
                LoggedIn             = loggedIn,
                CompanyBossFirstName = employer.FirstName,
                CompanyBossLastName  = employer.LastName,
                CompanyName          = employer.CompanyName,
                CompanyLocation      = employer.CurrentAddress,
                Position             = ad.PositionName,
                Description          = ad.Description,
                ContactEmail         = employer.ContactEmail,
                ContactPhone         = employer.ContactPhone
            };

            return(detailedAd);
        }
Exemple #5
0
        public IActionResult Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var advert = _advertManager.GetAdvert(id.Value);

            if (advert == null)
            {
                return(NotFound());
            }
            AdvertDetailViewModel vm = new AdvertDetailViewModel
            {
                Advert = advert
            };

            return(View(vm));
        }