public IActionResult Edit(int id)
        {
            var email       = User.FindFirst("emails").Value;
            var application = _applicationData.GetUserApplications(email).FirstOrDefault(a => a.ApplicationId == id);

            if (application == null)
            {
                return(View("NotFound"));
            }
            var jobOffer = _jobOfferData.FindById(application.JobOfferId);

            if (jobOffer == null)
            {
                return(View("NotFound"));
            }

            var applyViewModel = new ApplyViewModel();

            applyViewModel.ApplicationId      = application.ApplicationId;
            applyViewModel.Name               = application.Name;
            applyViewModel.CommunicationEmail = application.CommunicationEmail;
            applyViewModel.Phone              = application.Phone;
            applyViewModel.Info               = application.Info;
            applyViewModel.OfferName          = jobOffer.Name;
            applyViewModel.JobOfferId         = jobOffer.JobOfferId;
            applyViewModel.CvFile             = application.CvFile;

            return(View(applyViewModel));
//            return View("Apply", applyViewModel);
        }
示例#2
0
        public ActionResult SubmitApplication(ApplyViewModel applyViewModel, HttpPostedFileBase file)
        {
            if (String.IsNullOrEmpty(applyViewModel.Message) && file == null)
            {
                ModelState.AddModelError(String.Empty, "Please upload your résumé.");
            }

            if (!ModelState.IsValid)
            {
                foreach (var error in ViewData.ModelState["FirstName"].Errors)
                {
                    ModelState.AddModelError(String.Empty, error.ErrorMessage);
                }
                foreach (var error in ViewData.ModelState["LastName"].Errors)
                {
                    ModelState.AddModelError(String.Empty, error.ErrorMessage);
                }
                foreach (var error in ViewData.ModelState["EmailAddress"].Errors)
                {
                    ModelState.AddModelError(String.Empty, error.ErrorMessage);
                }


                return(View("Index", applyViewModel));
            }

            StringBuilder body = new StringBuilder();

            body.AppendLine("New Application Received From Website<br/><br/>");
            body.AppendFormat("First Name : {0}<br/>", applyViewModel.FirstName).AppendLine();
            body.AppendFormat("Last Name : {0}<br/>", applyViewModel.LastName).AppendLine();
            if (!String.IsNullOrEmpty(applyViewModel.Message))
            {
                body.AppendFormat("Message : {0}<br/>", applyViewModel.Message.Replace("\r\n", "<br/>")).AppendLine();
            }


            String fullName    = String.Format("{0} {1}", applyViewModel.FirstName, applyViewModel.LastName);
            string fromAddress = applyViewModel.EmailAddress;

            MailAddress from = new MailAddress(fromAddress, fullName);

            MailMessage message = new MailMessage();

            message.From = from;
            message.Body = body.ToString();
            message.To.Add(new MailAddress("*****@*****.**"));
            message.IsBodyHtml = true;
            message.Subject    = "New Application Received From Website";

            if (file != null && file.ContentLength > 0)
            {
                message.Attachments.Add(new Attachment(file.InputStream, System.IO.Path.GetFileName(file.FileName)));
            }

            EmailService.SendEmail(message);


            return(View("Success"));
        }
示例#3
0
        /// <summary>
        /// Apply to post directly from the list of posts.
        /// </summary>
        /// <param name="id">Id of the post to apply for.</param>
        /// <returns></returns>
        public async Task <IActionResult> Apply(int id)
        {
            var post = await Db.Post.FirstOrDefaultAsync(x => x.Id == id);

            ApplyViewModel viewModel = null;

            if (post != null)
            {
                // Create a new view model
                viewModel = new ApplyViewModel {
                    Post = post
                };


                // 1. User must log in if not already logged in
                //var value = HttpContext.Session.GetString("Person");
                //if (string.IsNullOrEmpty(value))
                //{
                //    var person = new SignedInPerson("Anders Hundborg", "*****@*****.**", 1);


                //    var serialisedDate = JsonConvert.SerializeObject(person);
                //    HttpContext.Session.SetString("Person", serialisedDate);
                //}
                //else
                //{
                //    var person = JsonConvert.DeserializeObject<Person>(value);
                //}

                // 2. Add post to briefcase
                // 3. Start interview
            }
            return(View("Apply", viewModel));
        }
示例#4
0
        public void Setup()
        {
            unitOfWork   = new UnitOfWork();
            appViewModel = new ApplicationViewModel <Model.Donor>();
            Address homeAddress = new Address();

            homeAddress.City      = "Cluj-Napoca";
            homeAddress.Street    = "DeathIsSweet";
            homeAddress.StreetNo  = "123";
            homeAddress.AddressID = 7000;
            Person person = new Person();

            person.FirstName  = "Alex";
            person.LastName   = "Alex";
            person.PersonID   = 7000;
            appViewModel.User = new Model.Donor {
                PersonID = 7000, Person = person, ResidenceAddress = homeAddress, ResidenceID = 7000
            };

            dispatcherWrapper = new Core.UnitTests.Dependencies.DispatcherWrapper();
            parentPage        = new ParentPage();
            viewModel         = new ApplyViewModel(unitOfWork, appViewModel, dispatcherWrapper)
            {
                ParentPage = parentPage
            };
        }
        public void TestUnder18ReturnsNoCard()
        {
            // Arrange
            ApplyController controller = new ApplyController();

            var model = new ApplyViewModel()
            {
                DOB       = DateTime.Now,
                FirstName = "Uder18Test",
                LastName  = "Uder18Test",
                Income    = 20000m
            };

            SeedDB(context);

            //Act
            var result = (RedirectToRouteResult)controller.Index(model);

            result.RouteValues.TryGetValue("action", out object routeNameObj);
            result.RouteValues.TryGetValue("cardApplicationID", out object cardApplicationIDObj);

            var cardApplicationID = Int16.Parse(cardApplicationIDObj.ToString());
            var cardApplication   = context.CardApplications.First(c => c.CardApplicationID == cardApplicationID);

            //Assert
            Assert.AreEqual("Results", routeNameObj.ToString());
            Assert.AreEqual(0, cardApplication.Cards.Count);
        }
        public void TestOver30000ReturnsBarclayCard()
        {
            // Arrange
            ApplyController controller = new ApplyController();

            var model = new ApplyViewModel()
            {
                DOB       = new DateTime(1980, 1, 1),
                FirstName = "Over30kTest",
                LastName  = "Over30kTest",
                Income    = 30001m
            };

            SeedDB(context);

            //Act
            var result = (RedirectToRouteResult)controller.Index(model);

            result.RouteValues.TryGetValue("action", out object routeNameObj);
            result.RouteValues.TryGetValue("cardApplicationID", out object cardApplicationIDObj);

            var cardApplicationID = Int16.Parse(cardApplicationIDObj.ToString());
            var cardApplication   = context.CardApplications.First(c => c.CardApplicationID == cardApplicationID);

            //Assert
            Assert.AreEqual("Results", routeNameObj.ToString());
            Assert.AreEqual(1, cardApplication.Cards.Count);
            Assert.AreEqual("BarclayCard", cardApplication.Cards.First().Name);
        }
        public IActionResult Apply(string jobOfferId)
        {
            var candidateId = this.candidatesService.GetCandidateIdByUsername(this.User.Identity.Name);

            if (candidateId == null)
            {
                return(this.RedirectToAction("CreateProfile", "Candidates"));
            }

            var candidateDetails         = this.candidatesService.GetProfileDetails <CandidateContactDetailsViewModel>(candidateId);
            var candidateDocumentDetails = this.documentsService.GetAllDocumentsForCandidate <CandidateDocumentsDropDownViewModel>(candidateId);
            var jobOfferDetails          = this.jobOffersService.GetDetails <JobApplicationJobOfferDetailsViewModel>(jobOfferId);

            if (candidateDetails == null || candidateDocumentDetails == null || jobOfferDetails == null)
            {
                return(this.NotFound());
            }

            var viewModel = new ApplyViewModel
            {
                CandidateDetails = candidateDetails,
                Documents        = candidateDocumentDetails,
                JobOfferDetails  = jobOfferDetails,
                JobOfferId       = jobOfferId,
                CandidateId      = candidateId,
            };

            return(this.View(viewModel));
        }
        private async Task <IActionResult> UploadCvFile(ApplyViewModel applyViewModel)
        {
            var formFile = applyViewModel.RealFile;

            if ((formFile == null || formFile.Length <= 0) && String.IsNullOrEmpty(applyViewModel.CvFile))
            {
                TempData["BadUpload"] = "File not specified or upload failed";
                return(View("Apply", applyViewModel));
            }
            TempData["BadUpload"] = null;
            if (!ModelState.IsValid)
            {
                return(View("Apply", applyViewModel));
            }

            if (formFile != null)
            {
                var    uploadSuccess = false;
                string uploadedUri   = null;
                using (var stream = formFile.OpenReadStream())
                {
                    (uploadSuccess, uploadedUri) = await BlobStorageService.UploadToBlob(formFile.FileName,
                                                                                         _configuration["storageconnectionstring"], null, stream);
                }
                if (!uploadSuccess)
                {
                    TempData["BadUpload"] = "File not specified or upload failed";
                    return(View("Apply", applyViewModel));
                }
                applyViewModel.CvFile = uploadedUri;
            }

            return(null);
        }
示例#9
0
        public JsonResult Apply(ApplyViewModel model)
        {
            CustomJsonResult reuslt = new CustomJsonResult();

            reuslt = BizFactory.CarInsureCommissionRate.Apply(this.CurrentUserId, model.CommissionRate, model.Reason);

            return(reuslt);
        }
示例#10
0
        ApplySavesTheRecordCorrectly()
        {
            AutoMapperInitializer.InitializeMapper();
            var context = InMemoryDbContextInitializer.InitializeContext();
            await context.ApplicationStatuses.AddAsync(new JobApplicationStatus { Name = "Under Review", Id = 1 });

            await context.SaveChangesAsync();

            var repository          = new EfDeletableEntityRepository <JobApplication>(context);
            var documentsRepository = new EfDeletableEntityRepository <JobApplicationDocument>(context);
            var jobOffersRepository = new Mock <EfDeletableEntityRepository <JobOffer> >(context);

            jobOffersRepository.Setup(r => r.AllAsNoTracking()).Returns(new List <JobOffer>
            {
                new JobOffer
                {
                    Id       = "333",
                    Position = "CEO",
                    Employer = new Employer
                    {
                        ContactPersonEmail = "email",
                        ContactPersonNames = "Georgi Georgiev",
                        ApplicationUser    = new ApplicationUser
                        {
                            Email = "OtherEmail"
                        },
                    },
                },
            }.AsQueryable());

            var service = this.GetMockedService(repository, documentsRepository, jobOffersRepository.Object);

            var model = new ApplyViewModel
            {
                JobOfferId       = "333",
                CandidateId      = "1",
                CandidateDetails = new CandidateContactDetailsViewModel
                {
                    ApplicationUserEmail = "userEmail",
                    FirstName            = "Ivan",
                    LastName             = "Ivanov",
                    PhoneNumber          = "1234567890",
                },
                JobOfferDetails = new JobApplicationJobOfferDetailsViewModel
                {
                    Position = "CEO",
                },
                DocumentIds = new List <string> {
                    "First"
                },
            };
            var result = service.Apply(model, "someUrl");

            Assert.NotNull(result);
            Assert.NotEqual(0, context.JobApplicationDocuments.Count());
        }
示例#11
0
        public async Task <IActionResult> Apply(int id, ApplyViewModel model)
        {
            if (!await this.service.Apply(ClaimsHelper.GetUserId(this.User), id, model.LinkedinUrl))
            {
                return(StatusCode(422));
            }


            return(Ok(true));
        }
示例#12
0
        //public ActionResult Delete(long id)
        //{

        //        dao.RemoveJobOffer((long) id);

        //    return RedirectToAction("ShowJobOfferList", "Career", null);
        //}
        public ActionResult Apply(long id)
        {
            JobOffer       jo  = dao.GetJobOfferByOfferNumber(id);
            ApplyViewModel avm = new ApplyViewModel();

            avm.OfferNumber    = jo.OfferNumber;
            avm.Location       = jo.Location;
            avm.OfferName      = jo.Name;
            avm.JobDescription = jo.JobDescription;
            return(View(avm));
        }
        /// <summary>
        ///     Show the details of a particular application.
        /// </summary>
        /// <remarks>
        ///     If no id is sent, display a bad request error page.
        ///     Else
        ///         Get the application from the database with a matching id.
        ///         Attach the user associated with the application.
        ///         Send the application as the model to populate the Detail view.
        /// </remarks>
        /// <param name="id">The id of the application record in the database</param>
        /// <returns>The Application Detail View, with an Application parameter</returns>
        // GET: ViewApps/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ApplyViewModel application = _db.Applications.Where(a => a.ApplicationId == id).Include(a => a.User).Single();
            Image          source      = Image.FromFile(Server.MapPath("/images/") + application.FileName);
            ImageFormat    format      = source.RawFormat;

            source.Dispose();
            ImageHelper.RotateImageByExifOrientationData(Server.MapPath("/images/") + application.FileName, Server.MapPath("/images/") + application.FileName, format);

            return(View(application));
        }
        private bool SendApplicationToDatabase(ApplyViewModel applyViewModel)
        {
            if (applyViewModel.ApplicationId > 0)
            {
                var application = _applicationData.FindById(applyViewModel.ApplicationId);
                if (application == null)
                {
                    return(false);
                }
                application.Name  = applyViewModel.Name;
                application.Phone = applyViewModel.Phone;
                application.CommunicationEmail = applyViewModel.CommunicationEmail;
                application.Info   = applyViewModel.Info;
                application.CvFile = applyViewModel.CvFile;

                _applicationData.Update(application);
            }
            else
            {
                var jobOffer = _jobOfferData.FindById(applyViewModel.JobOfferId);
                if (jobOffer == null)
                {
                    return(false);
                }
                var application = new Application();
                application.UserEmail          = User.FindFirst("emails").Value;
                application.ApplicationId      = 0;
                application.JobOfferId         = applyViewModel.JobOfferId;
                application.OfferName          = jobOffer.Name;
                application.Name               = applyViewModel.Name;
                application.Phone              = applyViewModel.Phone;
                application.CommunicationEmail = applyViewModel.CommunicationEmail;
                application.Info               = applyViewModel.Info;
                application.CvFile             = applyViewModel.CvFile;
                _applicationData.Add(application);

                var hrEmail = _jobOfferData.GetHrEmail(applyViewModel.JobOfferId);

                if (hrEmail != null)
                {
                    var apikey = _configuration["sendgridapikey"];
                    SendGridService.SendEmail(hrEmail, applyViewModel.OfferName, apikey, application.CvFile);
                }
            }

            _applicationData.Commit();
            return(true);
        }
示例#15
0
        public ActionResult ApplyForm()
        {
            ApplyViewModel viewModel = new ApplyViewModel();

            //Build User & UserID
            using (_db)
            {
                //var user = (from u in db.Users
                //             where u.UserName == User.Identity.Name
                //            select u).Single();
                var user = _db.Users.Single(u => u.UserName == User.Identity.Name);

                viewModel.User   = user;
                viewModel.UserId = user.Id;
            }
            return(View(viewModel));
        }
        public async Task <IActionResult> Apply(ApplyViewModel applyViewModel)
        {
            var uploadResult = await UploadCvFile(applyViewModel);

            if (uploadResult != null)
            {
                return(uploadResult);
            }

            if (!SendApplicationToDatabase(applyViewModel))
            {
                return(View("Apply", applyViewModel));
            }

            TempData["GoodUpload"] = "Application uploaded succesfully!";
            return(RedirectToAction("Index", "Applications"));
        }
示例#17
0
        public ActionResult Apply(ApplyViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Detail", new { listingId = model.ListingId }));
            }

            _repo.Add(new Applicant
            {
                ListingId = model.ListingId,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Email     = model.Email,
                Phone     = model.Phone
            });

            return(RedirectToAction("Detail", new { listingId = model.ListingId }));
        }
        public IActionResult Apply(int id)
        {
            var jobOffer = _jobOfferData.FindById(id);

            if (jobOffer == null)
            {
                return(View("NotFound"));
            }

            var applyViewModel = new ApplyViewModel();

            applyViewModel.ApplicationId = 0;
            applyViewModel.Info          = "sample info";
            applyViewModel.OfferName     = jobOffer.Name;
            applyViewModel.JobOfferId    = jobOffer.JobOfferId;

            return(View(applyViewModel));
        }
示例#19
0
        public void ApplyViewModel_ShouldAssignProppertiesCorrectly()
        {
            // Arrange
            ApplyViewModel apply = new ApplyViewModel();

            // Act
            apply.UserName = "******";
            apply.UserId   = "123";
            Guid guid = Guid.NewGuid();

            apply.id       = guid;
            apply.PostedOn = new DateTime(2002, 2, 2);

            // Assert
            Assert.AreEqual(apply.UserId, "123");
            Assert.AreEqual(apply.UserName, "Pesho");
            Assert.AreEqual(apply.id, guid);
            Assert.AreEqual(apply.PostedOn, new DateTime(2002, 2, 2));
        }
示例#20
0
        public ActionResult Apply([FromForm] ApplyViewModel model)
        {
            try {
                string   UserId = _usermanager.GetUserId(User);
                JobModel job    = _context.jobs.Where(x => x.Id == model.JobId).FirstOrDefault();

                UserJob user = new UserJob {
                    UserId = UserId, JobId = job.Id
                };
                _context.Candidates.Add(user);
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                return(BadRequest());
            }


            return(Ok());
        }
        public async Task <IActionResult> Apply(ApplyViewModel input)
        {
            var candidateId = this.candidatesService.GetCandidateIdByUsername(this.User.Identity.Name);

            if (candidateId == null)
            {
                return(this.RedirectToAction("CreateProfile", "Candidates"));
            }

            if (!this.ModelState.IsValid)
            {
                var candidateDetails         = this.candidatesService.GetProfileDetails <CandidateContactDetailsViewModel>(input.CandidateId);
                var candidateDocumentDetails = this.documentsService.GetAllDocumentsForCandidate <CandidateDocumentsDropDownViewModel>(input.CandidateId);
                var jobOfferDetails          = this.jobOffersService.GetDetails <JobApplicationJobOfferDetailsViewModel>(input.JobOfferId);

                input.CandidateDetails = candidateDetails;
                input.Documents        = candidateDocumentDetails;
                input.JobOfferDetails  = jobOfferDetails;
                return(this.View(input));
            }

            if (this.jobApplicationService.HasCandidateAppliedForOffer(input.CandidateId, input.JobOfferId))
            {
                this.TempData["AlreadyAppliedMessage"] = GlobalConstants.CandidateAlreadyApplied;
                return(this.RedirectToAction(nameof(this.All)));
            }

            var jobApplicationBaseUrl = $"{this.Request.Scheme}://{this.Request.Host}/JobApplications/Details/";
            var jobApplicationId      = await this.jobApplicationService.Apply(input, jobApplicationBaseUrl);

            if (jobApplicationId == null)
            {
                return(this.RedirectToAction("Error", "Home"));
            }
            else
            {
                this.TempData["SuccessfulApplication"] = GlobalConstants.JobApplicationSuccessfullySubmitted;
                return(this.RedirectToAction(nameof(this.All)));
            }
        }
示例#22
0
        public ActionResult ApplyForm([Bind(Include = "Age,Height,Weight,Notes,UserID")] ApplyViewModel model, HttpPostedFileBase uploadFile)
        {
            model.User = _db.Users.Find(model.UserId);

            //Upload File to Directory
            if (uploadFile != null && uploadFile.ContentType.Contains("image"))
            {
                string path      = Server.MapPath("/images/");
                string imagePath = "";
                try
                {
                    string extension   = Path.GetExtension(uploadFile.FileName);
                    string currentTime = "" + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second +
                                         DateTime.Now.Millisecond;
                    imagePath = imagePath + model.User.FirstName + "_" + currentTime + "_ApplicationPhoto" + extension;
                    uploadFile.SaveAs(path + imagePath);
                }
                catch (Exception ex)
                {
                    Console.Write("ERROR:" + ex.Message);
                }
                model.FileName = imagePath;
            }
            else
            {
                return(View(model));
            }

            //Save Application to DB
            if (ModelState.IsValid)
            {
                _db.Applications.Add(model);
                _db.SaveChanges();
                SendAppliedConfirmation(model.User.UserName);
                return(RedirectToAction("Success"));
            }

            return(View(model));
        }
示例#23
0
        public async Task <IViewComponentResult> InvokeAsync(ApplyViewModel viewModelFromController)
        {
            // No view model yet
            if (viewModelFromController == null)
            {
                var interview = await GetData();

                ApplyViewModel viewModel = null;
                await Task.Run(() =>
                {
                    viewModel = new ApplyViewModel
                    {
                        Interview   = interview,
                        CurrentStep = 0
                    };
                });

                return(View(viewModel));
            }
            // View model already instantiated
            return(View(viewModelFromController));
        }
示例#24
0
        public async Task <IActionResult> Apply(long id)
        {
            List <Application> applys = await _applicationDbContext.Applications.Where(a => a.Enabled == true).ToListAsync();

            foreach (Application apply in applys)
            {
                if (apply.Blocktime < DateTime.Now)
                {
                    apply.Enabled = false;
                }
            }
            _applicationDbContext.Applications.UpdateRange(applys);
            await _applicationDbContext.SaveChangesAsync();

            ViewBag.id = id;
            Student stu = await _applicationDbContext.Students.SingleOrDefaultAsync(s => s.ID == id);

            if (stu == null)
            {
                return(NotFound());
            }
            List <long> departids = await _applicationDbContext.DtoMMappings.Where(d => d.MemberID == id).Select(d => d.DepartID).ToListAsync();

            List <Application> applications = new List <Application>();

            if (departids.Count() != 0)
            {
                applications = await _applicationDbContext.Applications.Where(a => a.Grade == stu.Grade && a.Institute == stu.Institute &&
                                                                              a.Enabled == true && (!(departids.Contains(a.DepartID)))).ToListAsync();
            }
            else
            {
                applications = await _applicationDbContext.Applications.Where(a => a.Grade == stu.Grade && a.Institute == stu.Institute && a.Enabled == true).ToListAsync();
            }
            if (applications == null)
            {
                return(NotFound());
            }
            foreach (Application application in applications)
            {
                DtoAMapping dtoAMapping = await _applicationDbContext.DtoAMappings.Where(d => d.ApplicationID == application.ID && d.StudentID == id).FirstOrDefaultAsync();

                if (dtoAMapping == null)
                {
                    dtoAMapping = new DtoAMapping
                    {
                        ApplicationID = application.ID,
                        DepartID      = application.DepartID,
                        StudentID     = id,
                        Duty          = "",
                        Enabled       = false
                    };
                    await _applicationDbContext.DtoAMappings.AddAsync(dtoAMapping);

                    await _applicationDbContext.SaveChangesAsync();
                }
            }
            List <ApplyViewModel> applyViewModels = new List <ApplyViewModel>();

            for (int i = 0; i < applications.Count(); i++)
            {
                DtoAMapping dtoa = await _applicationDbContext.DtoAMappings.Where(d => d.ApplicationID == applications[i].ID && d.StudentID == id).FirstOrDefaultAsync();

                ApplyViewModel applyviewmodel = new ApplyViewModel
                {
                    DepartName    = await _applicationDbContext.Departs.Where(d => d.ID == applications[i].DepartID).Select(d => d.Name).FirstOrDefaultAsync(),
                    ApplicationID = applications[i].ID,
                    Count         = applications[i].Count,
                    DepartID      = applications[i].DepartID,
                    Address       = applications[i].Address,
                    Duty          = dtoa.Duty,
                    Time          = applications[i].Time,
                    Enabled       = dtoa.Enabled
                };
                applyViewModels.Add(applyviewmodel);
            }
            return(View(applyViewModels));
        }
示例#25
0
        public ViewResult Apply()
        {
            ApplyViewModel model = new ApplyViewModel();

            return(View(model));
        }
示例#26
0
        public override void Execute(object obj)
        {
            var vm = new ApplyViewModel();

            this.Sheel.Show(vm);
        }
示例#27
0
        public async Task <string> Apply(ApplyViewModel input, string jobApplicationBaseUrl)
        {
            var jobApplication = AutoMapperConfig.MapperInstance.Map <JobApplication>(input);

            var applicationStatusId = this.applicationStatusRepository
                                      .AllAsNoTracking()
                                      .Where(jas => jas.Name == "Under Review")
                                      .Select(jas => jas.Id)
                                      .FirstOrDefault();

            jobApplication.ApplicationStatusId = applicationStatusId;
            jobApplication.CreatedOn           = DateTime.UtcNow;

            var jobApplicationDocuments = new List <JobApplicationDocument>();

            foreach (var documentId in input.DocumentIds)
            {
                var jobApplicationDocument = new JobApplicationDocument
                {
                    JobApplication = jobApplication,
                    DocumentId     = documentId,
                    CreatedOn      = DateTime.UtcNow,
                };
                jobApplicationDocuments.Add(jobApplicationDocument);
            }

            try
            {
                await this.jobApplicationsRepository.AddAsync(jobApplication);

                await this.jobApplicationsRepository.SaveChangesAsync();

                await this.jobApplicationDocumentsRepository.AddRangeAsync(jobApplicationDocuments);

                await this.jobApplicationDocumentsRepository.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(null);
            }

            var jobOfferDetails = this.jobOfferRepository
                                  .AllAsNoTracking()
                                  .Where(jo => jo.Id == input.JobOfferId)
                                  .Select(jo => new
            {
                jo.Position,
                jo.Employer.ContactPersonEmail,
                EmployerAccountEmail = jo.Employer.ApplicationUser.Email,
                jo.Employer.ContactPersonNames,
            })
                                  .FirstOrDefault();

            var sb = new StringBuilder();

            sb.Append(string.Format(GlobalConstants.NewJobApplicationReceivedOpening, jobOfferDetails.ContactPersonNames, jobOfferDetails.Position, input.CandidateDetails.FirstName + " " + input.CandidateDetails.LastName, input.CandidateDetails.ApplicationUserEmail));
            if (input.CandidateDetails.PhoneNumber != null)
            {
                sb.Append(string.Format(GlobalConstants.NewJobApplicationReceivedCandidatePhoneNumber, input.CandidateDetails.PhoneNumber));
            }

            sb.Append(string.Format(GlobalConstants.NewJobApplicationReceivedClosing, HtmlEncoder.Default.Encode(jobApplicationBaseUrl + jobApplication.Id)));

            await this.emailSender.SendEmailAsync(this.configuration["DefaultAdminCredentials:Email"], this.configuration["DefaultAdminCredentials:Username"], jobOfferDetails.ContactPersonEmail, $"New Job Application received for Job Offer {jobOfferDetails.Position}", sb.ToString(), null, jobOfferDetails.EmployerAccountEmail);

            return(jobApplication.Id);
        }
示例#28
0
        public ActionResult Apply(ApplyViewModel model)
        {
            //bool letterSaved = dao.SaveFileOnServer(Server, model.LetterFile, AppConfig.LettersFolderRelative);
            //bool photoSaved = dao.SaveFileOnServer(Server, model.PhotoFile, AppConfig.PhotosFolderRelative);
            if (ModelState.IsValid)
            {
                bool   cvSaved = true;
                string path    = null;
                if (model.CVFile != null)
                {
                    path    = Utils.Utils.CreatePath(Server, model.CVFile, Utils.AppConfig.CVFolderRelative);
                    cvSaved = dao.SaveFileOnServer(path, model.CVFile);
                }
                Person person = new Person()
                {
                    CanContact             = model.CanContact,
                    City                   = model.City,
                    CVPath                 = path,
                    Email                  = model.Email,
                    Name                   = model.Name,
                    PersonalDataProcessing = model.PersonalDataProcessing,
                    PhoneNumber            = model.PhoneNumber,
                    Street                 = model.Street,
                    Surname                = model.Surname,
                    Zip        = model.Zip,
                    Candidates = new List <Candidate>(),
                    Notes      = new List <PersonNote>(),
                    Tags       = new List <SkillTag>(),
                };

                Recruitment recruitment = dao.GetRecruitmentById(model.OfferNumber);

                Candidate candidate = new Candidate()
                {
                    FinancialExpectations = model.FinancialExpectations,
                    Invited           = false,
                    MeetsRequirements = true,
                    Person            = person,
                    ReadyToMove       = model.ReadyToMove,
                    Recruitment       = recruitment,
                    ApplyTime         = DateTime.Now
                };

                RecruitmentEvent ev = new RecruitmentEvent()
                {
                    Author      = "HR Manager",
                    AuthorId    = "HR Manager",
                    Recruitment = recruitment,
                    Time        = DateTime.Now,
                    Event       = person.GetFullName() + " zaaplikował/a na stanowisko"
                };


                GIDOLog gl = new GIDOLog()
                {
                    Author   = person.Name + " " + person.Surname,
                    AuthorId = "",
                    Date     = DateTime.Now,
                    Changes  = "Zmodyfikowano dane użytkownika:" + person.ToString()
                };
                dao.SaveGIDOLog(gl);

                recruitment.Events.Add(ev);
                recruitment.Candidate.Add(candidate);

                //dao.SavePerson(person);
                //dao.SaveCandidate(candidate);
                dao.UpdatateRecruitment(recruitment);

                return(View("ApplyComplete", cvSaved));
            }
            else
            {
                return(View(model));
            }
        }