public string SavePerson([FromBody] NewPerson newperson)
        {
            string result      = "";
            var    person      = newperson.Person;
            var    reviewsetup = newperson.ReviewSetup;

            person.AccountID         = SecurityContextManager.Current.CurrentAccount.ID;
            person.TerminationDate   = null;
            person.DateAcceptedTerms = null;
            person.Password          = IdeaSeed.Core.SecurityUtils.GetMd5Hash(person.Password);
            var p = new PersonServices().Save(person);

            if (person.ManagerID == -1)
            {
                person.ManagerID = p.ID;
                new PersonServices().Save(p);
            }

            foreach (var m in person.Memberships)
            {
                m.PersonID = person.ID;
                new TeamMemberServices().Save(m);
            }
            var review = new Review();

            review.AccountID        = SecurityContextManager.Current.CurrentAccount.ID;
            review.ChangedBy        = SecurityContextManager.Current.CurrentUser.ID;
            review.DateCreated      = DateTime.Now;
            review.DueDate          = reviewsetup.DueDate;
            review.EnteredBy        = SecurityContextManager.Current.CurrentUser.ID;
            review.EnteredFor       = person.ID;
            review.IsActive         = true;
            review.IsCurrent        = true;
            review.LastUpdated      = DateTime.Now;
            review.ReviewTemplateID = reviewsetup.TemplateID;
            review.StartDate        = reviewsetup.StartDate;
            review.Status           = (int)GoalStatus.ACCEPTED;
            review.Title            = person.Name + " - Due: " + review.DueDate.ToShortDateString();
            new ReviewServices().Save(review);

            var t = new ReviewTemplateServices().GetByID(review.ReviewTemplateID);

            foreach (var i in t.Questions)
            {
                var q = new ReviewQuestionScore();
                q.Comment          = "";
                q.DateCreated      = DateTime.Now;
                q.EnteredBy        = SecurityContextManager.Current.CurrentUser.ID;
                q.Score            = 0;
                q.ReviewID         = review.ID;
                q.ReviewQuestionID = i.ID;
                new ReviewQuestionScoreServices().Save(q);
            }

            if (person.ReceiveCommentNotifications)
            {
                EmailHelper.SendNewEmployeeNotification(person, "");
            }
            IdeaSeed.Core.Data.NHibernate.NHibernateSessionManager.Instance.CloseSession();
            result = "1:Employee Added Succesfully!:People/" + person.Email;

            var _cache = new MemcacheCacheAdapter();

            _cache.Remove(SecurityContextManager
                          .Current
                          .CurrentUser.AccountID.ToString() + "_DepartmentsList");
            var list = new PersonServices().GetByAccountID(SecurityContextManager.Current.CurrentAccount.ID).OrderBy(o => o.LastName).ToList <Person>();

            _cache.Store(SecurityContextManager
                         .Current
                         .CurrentUser.AccountID.ToString() + "_DepartmentsList", list);

            return(result);
        }
        protected void SaveClicked(object o, EventArgs e)
        {
            foreach (DataListItem row in dlPeople.Items)
            {
                if (row.ItemType == ListItemType.Item || row.ItemType == ListItemType.AlternatingItem)
                {
                    if (((IdeaSeed.Web.UI.CheckBox)row.FindControl("cbSelected")).Checked)
                    {
                        var p = new PersonServices().GetByID(Convert.ToInt32(((IdeaSeed.Web.UI.CheckBox)row.FindControl("cbSelected")).Attributes["itemid"]));

                        if (cbIsManagerFilter.Checked)
                        {
                            p.IsManager = true;
                        }
                        if (ddlManagerFilter.SelectedIndex > 0)
                        {
                            p.ManagerID = Convert.ToInt32(ddlManagerFilter.SelectedValue);
                        }
                        if (ddlDepartmentFilter.SelectedIndex > 0)
                        {
                            p.DepartmentID = Convert.ToInt32(ddlDepartmentFilter.SelectedValue);
                        }
                        if (ddlSecurityRoleFilter.SelectedIndex > 0)
                        {
                            p.RoleID = Convert.ToInt32(ddlSecurityRoleFilter.SelectedValue);
                        }
                        if (tbHireDateFilter.SelectedDate != null)
                        {
                            p.HireDate = tbHireDateFilter.SelectedDate;
                        }
                        if (ddlTeamFilter.SelectedIndex > 0)
                        {
                            var tm = new TeamMember();
                            tm.HasAccess = true;
                            tm.IsActive  = true;
                            tm.IsManager = false;
                            tm.PersonID  = p.ID;
                            tm.TeamID    = Convert.ToInt32(ddlTeamFilter.SelectedValue);
                            new TeamMemberServices().Save(tm);
                        }

                        if (
                            (p.DepartmentID != 0) &&
                            (p.HireDate != null) &&
                            (p.RoleID != 0) &&
                            (p.ManagerID != 0))
                        {
                            p.IsActive = true;
                        }
                        new PersonServices().Save(p);
                    }
                }
            }
            var _cache = new MemcacheCacheAdapter();

            _cache.Remove(SecurityContextManager
                          .Current
                          .CurrentUser.AccountID.ToString() + "_DepartmentsList");
            var list = new PersonServices().GetByAccountID(SecurityContextManager.Current.CurrentAccount.ID).OrderBy(l => l.LastName).ToList <Person>();

            _cache.Store(SecurityContextManager
                         .Current
                         .CurrentUser.AccountID.ToString() + "_DepartmentsList", list);
            LoadPeople();
        }