Example #1
0
        //this method enables admin to post jobs which is stored in the database
        public string CreateJobOffer(PostJobViewModel jobViewModel, string userId)
        {
            string result = "";

            try
            {
                JobOffers newJobOffers = new JobOffers()
                {
                    Title                 = jobViewModel.JobTitle,
                    AplicationDetails     = jobViewModel.JobDetails,
                    Deadline              = jobViewModel.Deadline,
                    DateCreated           = DateTime.Now,
                    Position              = jobViewModel.Position,
                    NoOfApplicant         = jobViewModel.NumApplicant,
                    AplicationRequirement = jobViewModel.Requirements,
                    Image                 = JobApplicationServices.ConvertToByte(jobViewModel.AppImage),
                    UserId                = userId
                };
                dbContext.jobOffers.Add(newJobOffers);
                dbContext.SaveChanges();

                result = "Success";
            }
            catch (Exception e)
            {
                result = "Error: " + e.Message;
            }
            return(result);
        }
Example #2
0
        //this method submits applicants form to the database and notifies the Admin that posted the job.
        public string SubmitApplication(ApplicationFormViewModel applicationForm, string NameLetter
                                        , string userid, string NameCV)
        {
            string result = "";

            try
            {
                Applications newApplications = new Applications()
                {
                    FirstName   = applicationForm.FirstName,
                    OtherNames  = applicationForm.OtherNames,
                    LastName    = applicationForm.LastName,
                    Address     = applicationForm.Address,
                    Phonenumber = applicationForm.Phonenumber,
                    State       = applicationForm.State,
                    JobID       = applicationForm.JobID,
                    UserId      = userid,
                    Email       = applicationForm.Email,
                    NameCV      = NameCV,
                    NameLetter  = NameLetter,
                    CV          = JobApplicationServices.ConvertToByte(applicationForm.CV),
                    Letter      = JobApplicationServices.ConvertToByte(applicationForm.Letter),
                    DateCreated = DateTime.Now,
                };

                string HTMLcontent = "This is to inform you that <b>" + applicationForm.FirstName
                                     + " " + applicationForm.LastName + "</b> Has applied for the job offer you posted on JB Limited";

                var res = isendMail.SendMail(
                    "*****@*****.**",
                    iadmin.GetAdminEmail(applicationForm.JobID),
                    "NEW APPLICANT",
                    HTMLcontent
                    );
                if (res.IsCompleted)
                {
                    dbContext.applications.Add(newApplications);
                    dbContext.SaveChanges();
                    result = "Success";
                }
                else
                {
                    result = "An internal Error Occured. Please check you Network";
                }
            }
            catch (Exception e)
            {
                result = "Error: " + e.Message;
            }
            return(result);
        }