Пример #1
0
        public ActionResult CreateGuide(int?applicantid, WelcomeGuide guide)
        {
            ViewBag.Templates = db.OnboardingTemplates.ToList();
            ViewBag.Branches  = db.Branches.ToList();
            if (!ModelState.IsValid)
            {
                guide.DateCreated = DateTime.UtcNow;
                guide.StartDate   = DateTime.UtcNow.AddDays(7);
                return(View(guide));
            }
            using (var db = new TalentContext())
            {
                guide.Status = Status.Review;
                db.WelcomeGuides.Add(guide);
                db.SaveChanges();

                if (guide.TemplateID != null)
                {
                    guide.WelcomeMessage = db.OnboardingTemplates.Find(guide.TemplateID).WelcomeMessage;
                    var activities      = db.CompletedActivities.Where(x => x.OnboardingTemplateID == guide.ID).ToList();
                    var guideactivities = OnboardingUtilityHelper.ConvertToGuideActivities(activities, guide.ID);
                    //guide.CompletedActivities = OnboardingUtilityHelper.ConvertToGuideActivities(db.OnboardingTemplates.Find(guide.TemplateID).CompletedActivities.ToList(), guide.ID);
                    guide.previewurl = Guid.NewGuid().ToString();
                    db.CompletedActivities.AddRange(guideactivities);
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("Guide/Customize/" + guide.Name + "/" + guide.ID, "Onboarding"));
        }
Пример #2
0
        public ActionResult CreateGuide(int?applicantid = 0)
        {
            WelcomeGuide guide = new WelcomeGuide();

            guide.DateCreated = DateTime.Now;
            guide.StartDate   = DateTime.Now.AddDays(7);
            guide.JobSeekerID = applicantid;
            ViewBag.Templates = db.OnboardingTemplates.ToList();
            ViewBag.Branches  = db.Branches.ToList();
            return(View(guide));
        }
Пример #3
0
        public ActionResult Create(int?guideid, Employee data = null)
        {
            var employee = new Employee();

            if (data != null)
            {
                employee = data;
            }
            var employeecount = db.Employees.Count();

            employee.EmployeeNumber  = @"SN/" + String.Format("{0:D4}", employeecount + 1);
            ViewBag.OfficePositionID = new SelectList(db.OfficePositions, "OfficePositionID", "Title");
            if (guideid != null)
            {
                var guide = new WelcomeGuide();
                using (var db = new TalentContext())
                {
                    var _guide = db.WelcomeGuides.Find(guideid);
                    if (_guide == null)
                    {
                        return(HttpNotFound());
                    }
                    guide = _guide;

                    if ((guide.JobSeekerID == null) || (guide.JobSeekerID == 0))
                    {
                        string[] names = guide.Name.Split(' ');
                        employee.FirstName   = names[0];
                        employee.LastName    = names[1];
                        employee.DateOfBirth = DateTime.Now.AddYears(-20);
                    }
                    else
                    {
                        var jobapplicant = db.Applicants.Where(x => x.ID == guide.JobSeekerID).FirstOrDefault();
                        //employee.FirstName = jobapplicant.FirstName;
                        //employee.LastName = jobapplicant.LastName;
                        string[] names = guide.Name.Split(' ');
                        employee.FirstName   = names[0];
                        employee.LastName    = names[1];
                        employee.DateOfBirth = jobapplicant.DateOfBirth;
                        employee.PhoneNumber = jobapplicant.PhoneNumber;
                        employee.Address     = jobapplicant.Address;
                    }
                    employee.EmploymentDate   = guide.StartDate;
                    employee.OfficePositionID = db.OfficePositions.Where(x => x.Title == guide.Position).First().OfficePositionID;
                }
                ViewBag.GuideCreation = true;
                return(View(employee));
            }
            ViewBag.GuideCreation = false;
            return(View(employee));
        }
Пример #4
0
 public ActionResult EditGuide(int id, WelcomeGuide guide)
 {
     if (!ModelState.IsValid)
     {
         return(View(guide));
     }
     using (var db = new TalentContext())
     {
         db.WelcomeGuides.Add(guide);
         db.Entry(guide).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     return(RedirectToAction("Onboarding", "Admin"));
 }
Пример #5
0
        public ActionResult PreviewGuide(string guideurl)
        {
            var guide = new WelcomeGuide();

            using (var db = new TalentContext())
            {
                var _guide = db.WelcomeGuides.Where(x => x.previewurl == guideurl).First();
                if (_guide == null)
                {
                    return(HttpNotFound());
                }
                guide = _guide;
            }
            return(View(guide));
        }
Пример #6
0
        // [Route("Onboarding/Applicant/{guideurl}")]
        public ActionResult ValidateEmployee(int id)
        {
            var guide = new WelcomeGuide();

            using (var db = new TalentContext())
            {
                var _guide = db.WelcomeGuides.Where(x => x.ID == id).First();
                if (_guide == null)
                {
                    return(HttpNotFound());
                }
                guide = _guide;
            }
            var url = Url.Action("Personnel/Create", "Admin");

            return(View(url, guide));
        }
Пример #7
0
 public ActionResult CreateGuide(int?applicantid, WelcomeGuide guide)
 {
     ViewBag.Templates = db.OnboardingTemplates.ToList();
     ViewBag.Branches  = db.Branches.ToList();
     if (!ModelState.IsValid)
     {
         guide.DateCreated = DateTime.Now;
         guide.StartDate   = DateTime.Now.AddDays(7);
         return(View(guide));
     }
     using (var db = new TalentContext())
     {
         guide.Status = Status.Review;
         db.WelcomeGuides.Add(guide);
         db.SaveChanges();
     }
     return(View());
 }
Пример #8
0
        public ActionResult EditGuide(int id, WelcomeGuide guide, int?newStatus)
        {
            if (!ModelState.IsValid)
            {
                return(View(guide));
            }
            using (var db = new TalentContext())
            {
                guide.WelcomeMessage = WebUtility.HtmlEncode(guide.WelcomeMessage);
                db.WelcomeGuides.Add(guide);
                if (newStatus != null)
                {
                    switch (newStatus)
                    {
                    case 1:
                        guide.Status = Status.Published;
                        break;

                    case 2:
                        guide.Status = Status.Submitted;
                        break;

                    case 3:
                        guide.Status = Status.Complete;
                        break;

                    case 4:
                        guide.Status = Status.Closed;
                        break;
                    }
                }
                db.Entry(guide).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                if (newStatus == 3)
                {
                    return(RedirectToAction("Personnel/Create", "Admin", new { guideid = guide.ID }));
                }
            }
            return(RedirectToAction("Onboarding", "Admin"));
        }