Esempio n. 1
0
        public IActionResult ApplayToJob(string ProfileId, int AdvId)
        {
            Profile profile = _context.profiles.Where(a => a.Id == ProfileId).FirstOrDefault();

            var userId    = profile.UserID != null ? profile.UserID : null;
            var companyId = profile.CompanyID != null ? profile.CompanyID : null;

            var user = userId != null?_context.users.Find(userId) : null;

            var company = companyId != null?_context.companies.Find(companyId) : null;


            ApplayToJobVM app = new ApplayToJobVM();

            app.ProfileId   = profile.Id;
            app.Email       = profile.Email;
            app.PhoneNumber = profile.PhoneNumber;
            app.CompanyName = company != null ? company.Name : null;
            app.City        = company != null?_context.cities.Find(company.CityId).Name : _context.cities.Find(user.CityId).Name;

            app.Address         = company != null ? company.Adress : user.Address;
            app.AdvertisementId = AdvId;


            if (user != null)
            {
                app.FirstName = user.FirstName;
                app.LastName  = user.LastName;
                app.BirthDate = user.BirthDate;
                app.Gender    = user.Gender != null ? user.Gender.Name : null;
            }

            return(View(app));
        }
Esempio n. 2
0
        public IActionResult SubmitApply(int AdvId, ApplayToJobVM vm)
        {
            //2 metod
            //MemoryStream ms = new MemoryStream();
            //var f = vm.Cv.OpenReadStream();

            //f.CopyTo(ms);
            //byte[] c1 = ms.ToArray();
            Form form = new Form
            {
                Experience        = vm.WorkExpirience,
                MotivationMessage = vm.Note,
                ProfileId         = _userManager.GetUserId(User),
                Profile           = _context.profiles.Find(_userManager.GetUserId(User)),
                AdvertisementId   = AdvId,
                Advertisement     = _context.advertisements.Find(vm.AdvertisementId),
                Cv = GetByteArrayFromCv(vm.Cv)
            };

            _context.Add(form);
            _context.SaveChanges();
            return(RedirectToAction("GetAll", "Advertisement"));
        }