示例#1
0
 public ActionResult CreatePerson()
 {
     Person p = new Person();
     ViewBag.Teams = _teamRepository.GetAll().OrderBy(t => t.name);
     ViewBag.TeamId = p.teamId;
     return View(p);
 }
示例#2
0
        public ActionResult CreatePerson(Person person, string selectedTeam,string password1, string password2, string Administrator)
        {
            string name = User.Identity.Name;

                string token = WebSecurity.CreateUserAndAccount(person.email, password1,true);

                // Get the user id and add to the person object
                var up = _userProfileRepository.Get(u => u.UserName == person.email).First();

                person.userProfileId = up.UserId;
                person.createdAt = DateTime.Now;
                person.updatedAt = DateTime.Now;
                person.deleted = false;
                person.active = true;
                person.teamId = (selectedTeam != "") ? Int32.Parse(selectedTeam) : 0;

                try
                {
                    _personRepository.SaveOrUpdate(person);
                    if (!string.IsNullOrEmpty(Administrator))
                    {
                        Roles.AddUserToRole(person.email, "Administrator");
                    }
                    if (person.personTypeId)
                    {
                        Roles.AddUserToRole(person.email, "Manager");
                    }
                    Roles.AddUserToRole(person.email, "Member");
                }

                catch (Exception ex)
                {

                }

            return PartialView("_Create");
            //return Json(new { success = true });
        }
示例#3
0
        public ActionResult Create(PersonRating pr)
        {
            try
            {
                pr.updatedAt = DateTime.Now;
                pr.createdAt = DateTime.Now;

                _personratingRepository.Merge(pr);

            }
            catch (Exception ex)
            {
                throw ex;
            }

            Person person = new Person();
            var persons = _personRepository.Get(t => t.deleted == false && t.id == pr.ratedBy && t.id > 1);
            if (persons.Count() == 1)
            {
                person = persons.AsQueryable().First();
            }

            return PartialView("_RatingCreated");
        }
        public ActionResult Create(PersonRating pr)
        {
            PersonRating p = null;
            try
            {
                p = new PersonRating();

                p.createdAt = DateTime.Now;
                p.updatedAt = DateTime.Now;
                p.personid = pr.personid;
                p.ratedBy = pr.ratedBy;
                p.innovation = pr.innovation;
                p.innovationNotes = pr.innovationNotes;
                p.communication = pr.communication;
                p.communicationNotes = pr.communicationNotes;
                p.performance = pr.performance;
                p.performanceNotes = pr.performanceNotes;
                p.problemSolving = pr.problemSolving;
                p.problemSolvingNotes = pr.problemSolvingNotes;
                p.productivity = pr.productivity;
                p.productivityNotes = pr.productivityNotes;
                p.startDate = pr.startDate;
                p.endDate = pr.endDate;
                p.reasonForRating = pr.reasonForRating;

                _personratingRepository.SaveOrUpdate(p);

            }
            catch (Exception ex)
            {
                throw ex;
            }

            Person person = new Person();
            person.id = pr.ratedBy;
            var persons = _personRepository.Get(t => t.deleted == false && t.id == person.id && t.id > 1);
            if (persons.Count() == 1)
            {
                person = persons.AsQueryable().First();
            }

            return RedirectToAction("Index", "Search",person);
        }
示例#5
0
        public ActionResult EditPerson(Person person, string selectedTeam, string password1, string password2, string oldpassword, string Administrator)
        {
            if (!WebSecurity.UserExists(person.email))
            {
                WebSecurity.CreateUserAndAccount(person.email, password1);
            }

            // Get the user id and add to the person object
            if (person.userProfileId == 0)
            {
                var up = _userProfileRepository.Get(u => u.UserName == person.email).First();
                person.userProfileId = up.UserId;
            }

            // change password
            if (oldpassword.Length > 0 && password1.Length > 0)
            {
                bool changePasswordSucceeded;
                try
                {
                    changePasswordSucceeded = WebSecurity.ChangePassword(person.email, oldpassword, password1);
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }
            }

            if (!string.IsNullOrEmpty(Administrator))
            {
                if (Roles.IsUserInRole(person.email, "Administrator"))
                {
                    Roles.RemoveUserFromRole(person.email, "Administrator");
                }
            }
            if (!person.personTypeId)
            {
                if (Roles.IsUserInRole(person.email, "Manager"))
                {
                    Roles.RemoveUserFromRole(person.email, "Manager");
                }
            }
            person.updatedAt = DateTime.Now;
            person.teamId = (selectedTeam != "") ? Int32.Parse(selectedTeam) : 0;
            var s = _personRepository.GetSession();
            using (var tx = s.BeginTransaction())
            {
                try
                {
                    //_personRepository.SaveOrUpdate(person);
                    s.Merge<Person>(person);
                    tx.Commit();
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                }
            }
            return PartialView("_Edit");
        }