Exemplo n.º 1
0
        public ActionResult Application(CareersViewModel obj, FormCollection form)
        {
            var item = obj.JobApp;

            item.Submitted = DateTime.Now;

            int month = 0,
                day   = 0,
                year  = 0;

            if (form["Month"] != null)
            {
                int.TryParse(form["Month"].ToString(), out month);
            }
            if (form["Day"] != null)
            {
                int.TryParse(form["Day"].ToString(), out day);
            }
            if (form["Year"] != null)
            {
                int.TryParse(form["Year"].ToString(), out year);
            }

            var job = _jobRepo.FindBy(x => x.ID == item.JobID).FirstOrDefault();

            if (job != null)
            {
                item.AppJobID = job.JobID;
            }

            _uow.JobApplications.Add(item);
            _uow.Commit();

            dynamic email = new Email("JobApplication");

            email.To    = ConfigurationManager.AppSettings["JobApplicationEmail"];
            email.Bcc   = ConfigurationManager.AppSettings["DebugEmail"];
            email.Model = item;
            email.Send();

            //return Newtonsoft.Json.JsonConvert.SerializeObject(item);
            return(View("ApplicationSubmitted"));
        }
Exemplo n.º 2
0
        public ActionResult Apply(string slug)
        {
            CareersViewModel viewModel = new CareersViewModel();

            viewModel.Jobs    = _jobRepo.GetAllPublic();
            viewModel.JobList = JobList();
            int jobID = 0;
            var item  = _jobRepo.GetBySlug(slug);

            if (item != null)
            {
                jobID = item.ID;
            }
            viewModel.IsApplyView = true;
            viewModel.JobApp      = new JobApplication()
            {
                JobID = jobID, State = ""
            };
            return(View("Apply", viewModel));
        }
Exemplo n.º 3
0
        public ActionResult Index(CareersViewModel input)
        {
            using (TouchContext db = new TouchContext())
            {
                string extension = Request.Files[0]?.FileName.Split('.').Last();
                string fileName  = Request.Files[0]?.FileName.Split('.').First();
                input.Application.CvPath = fileName + DateTime.Now.ToFileTime() + "." + extension;
                var    file          = Request.Files[0];
                string savedFileName = Path.Combine(Server.MapPath("~/File/JobCv"), Path.GetFileName(input.Application.CvPath));
                file.SaveAs(savedFileName); // Save the file
                db.JobApplication.Add(input.Application);
                db.SaveChanges();
                input.Application = new JobApplication();
                input.Info        = db.CareerInformation.FirstOrDefault();
                input.IsSent      = true;
            }


            return(View(input));
        }
Exemplo n.º 4
0
        public ActionResult Index(string slug)
        {
            CareersViewModel viewModel = new CareersViewModel();

            if (string.IsNullOrEmpty(slug))
            {
                viewModel.Jobs    = _jobRepo.GetAllPublic();
                viewModel.JobList = JobList();
                viewModel.JobApp  = new JobApplication()
                {
                    State = ""
                };
                viewModel.IsApplyView = false;
                return(View(viewModel));
            }

            return(View("Detail", new BaseViewModel <Job>()
            {
                Item = _jobRepo.GetBySlug(slug)
            }));
        }
Exemplo n.º 5
0
        public ActionResult Index()
        {
            //sanitize url
            string inputUrlParam;
            string cleanUrlParam;

            if (RouteData.Values["careerName"] == null)
            {
                return(Redirect("/careers/administrative-assistant"));
            }
            else
            {
                inputUrlParam = RouteData.Values["careerName"].ToString();
                cleanUrlParam = URLFriendly(inputUrlParam);

                if (!inputUrlParam.Equals(cleanUrlParam))
                {
                    return(Redirect(cleanUrlParam));
                }
            }

            var db = new CareersDataContext();
            //var careersArray = db.Careers.ToArray(); //The ToArray executes the SQL call.

            /*var careersArray = db.Careers.Where(u => u.IsActive == 1).Select(u => u.CareerName);
             * var careersIdArray = db.Careers.Where(u => u.IsActive == 1).Select(u => u.Id);
             * SelectList careers = new SelectList(careersArray); //change the array to a select list*/

            var  careersViewModel   = new CareersViewModel();
            bool careerNameUrlFound = false;

            string careerNameUrl = "";

            if (RouteData.Values["careerName"] != null)  //This is from RouteConfig, so make sure it is up to date!
            {
                careerNameUrl = RouteData.Values["careerName"].ToString();
                careerNameUrl = careerNameUrl.Replace("-", " ");
            }

            //var list = db.Careers.ToList();
            long careerId = 1;
            var  list     = db.Careers.Where(u => u.IsActive == 1).OrderBy(u => u.CareerName).ToList();
            List <SelectListItem> careersList = new List <SelectListItem>();

            for (int i = 0; i < list.Count(); i++)
            {
                careersList.Add(new SelectListItem
                {
                    Text  = list.ElementAt(i).CareerName,
                    Value = list.ElementAt(i).CareerName // change to this if you want the value to be the Id: list.ElementAt(i).Id.ToString()
                });

                if (list.ElementAt(i).CareerName.ToLower().Equals(careerNameUrl))
                {
                    careerNameUrlFound = true;
                    careersList.ElementAt(i).Selected = true;

                    //set ViewModel parameters
                    careersViewModel.CareerName  = list.ElementAt(i).CareerName;
                    careersViewModel.Description = list.ElementAt(i).Description;
                    careersViewModel.ImageUrl    = list.ElementAt(i).ImageUrl;

                    //set careerId to use in the list of stories below.
                    careerId = list.ElementAt(i).Id;
                }
            }

            ViewBag.careersList = careersList;

            if (!careerNameUrlFound)
            {
                return(Redirect("/careers/administrative-assistant")); //anything after careers/ that is not valid will be redirected to aa.
            }

            //get stories from selected career, sort, and put in viewbag.
            var careerStoriesList = db.Stories.Where(u => u.IsActive == 1 && u.CareerId == careerId).OrderByDescending(u => u.PostCount).ToList();

            ViewBag.careerStoriesList = careerStoriesList;

            return(View(careersViewModel));
        }