public async Task <ActionResult> Apply(int id, ApplyViewModel model)
        {
            model.Jo = await _context.JobOffers.FirstOrDefaultAsync(x => x.Id == id);

            Company c = await _context.Companies.FirstOrDefaultAsync(x => x.Id == model.Jo.CompanyId);

            model.Company = c.Name;

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            JobApplication ja = new JobApplication
            {
                OfferId          = model.Jo.Id,
                FirstName        = model.FirstName,
                LastName         = model.LastName,
                PhoneNumber      = model.PhoneNumber,
                EmailAddress     = model.EmailAddress,
                ContactAgreement = model.ContactAgreement,
                CvUrl            = model.CvUrl,
            };
            await _context.JobApplications.AddAsync(ja);

            _context.Update(model.Jo);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Details", new { id = model.Jo.Id }));
        }
        public async Task <ActionResult> Apply(int id)
        {
            try
            {
                JobOffer jo = await _context.JobOffers.FirstOrDefaultAsync(x => x.Id == id);

                Company c = await _context.Companies.FirstOrDefaultAsync(x => x.Id == jo.CompanyId);

                ApplyViewModel model = new ApplyViewModel
                {
                    Jo      = jo,
                    Company = c.Name
                };
                return(View(model));
            }
            catch (Exception e)
            {
                return(BadRequest("Offer with this id doesn't exist!"));
            }
        }