Esempio n. 1
0
        public IActionResult Add(int AdvId)
        {
            AdvertisementAddVM    aavm;
            List <SelectListItem> jobs = _context.jobs.Select(a => new SelectListItem
            {
                Value = a.Id.ToString(),
                Text  = a.Name
            }).ToList();

            if (AdvId == 0)
            {
                aavm      = new AdvertisementAddVM();
                aavm.jobs = jobs;
            }
            else
            {
                aavm = _context.advertisements.Where(a => a.Id == AdvId).Select(a => new AdvertisementAddVM
                {
                    Id            = a.Id,
                    Name          = a.Name,
                    JobId         = a.JobId,
                    jobs          = jobs,
                    CurrentUserId = _userManager.GetUserId(User),
                    StartDate     = a.StartDate,
                    EndDate       = a.EndDate,
                    ProfileImg    = a.Profile.ProfilePicture,
                    Description   = a.Description,
                }).FirstOrDefault();
            }
            return(View("Add", aavm));
        }
Esempio n. 2
0
 public IActionResult Save(AdvertisementAddVM m)
 {
     if (ModelState.IsValid == true)
     {
         Advertisement a;
         if (m.Id == 0)
         {
             a           = new Advertisement();
             a.StartDate = DateTime.Now;
             _context.Add(a);
         }
         else
         {
             a = _context.advertisements.Find(m.Id);
         }
         a.Name        = m.Name;
         a.Description = m.Description;
         a.EndDate     = m.EndDate;
         a.JobId       = m.JobId;
         a.StartDate   = DateTime.Now;
         a.ProfileId   = _userManager.GetUserId(User);
         _context.SaveChanges();
     }
     return(Redirect("/Home/Index"));
 }
Esempio n. 3
0
        public IActionResult Details(int AdvId)
        {
            AdvertisementAddVM ad = _context.advertisements.Where(a => a.Id == AdvId).Select(a => new AdvertisementAddVM
            {
                Id            = a.Id,
                Job           = a.Job.Name,
                ProfileImg    = a.Profile.ProfilePicture,
                Description   = a.Description,
                StartDate     = a.StartDate,
                EndDate       = a.EndDate,
                ProfileId     = a.ProfileId,
                CompanyName   = a.Profile.Company.Name,
                UserName      = a.Profile.User.FirstName + ' ' + a.Profile.User.LastName,
                Name          = a.Name,
                CurrentUserId = _userManager.GetUserId(User)
            }).SingleOrDefault();

            return(View(ad));
        }