示例#1
0
 public bool MapUserToPerson(ApplicationUser user,Person person)
 {
     var um = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new EntityDbContext()));
     user.Person = person;
     var idResult = um.Update(user);
     return idResult.Succeeded;
 }
示例#2
0
        public ActionResult CreateOrEdit(Guid id)
        {
            bool isNew = false;
            var bo = _Service.GetSingle(id);
            if (bo == null)
            {
                bo = new Person();
                bo.ID = id;
                isNew = true;
            }
            var boVM = new PersonVM(bo);

            boVM.ParentItemColection = BusinessCollectionFactory<Department>.GetSelfReferentialItemCollection(true);
            boVM.CredentialsTypeCollection = BusinessCollectionFactory<CredentialsType>.GetPlainFacadeItemCollection();
            boVM.JobLevelCollection = BusinessCollectionFactory<JobLevel>.GetPlainFacadeItemCollection();
            boVM.JobTitleCollection = BusinessCollectionFactory<JobTitle>.GetPlainFacadeItemCollection();

            var editor = PageComponentRepository<PersonVM>.CreateOrEditDialog(boVM, isNew);
            return Json(editor);
        }
示例#3
0
文件: PersonVM.cs 项目: nongzhsh/Nccq
 public void MapToBo(Person bo)
 {
     bo.Name            = Name;
     bo.Description     = Description;
     bo.SortCode        = SortCode;
     bo.EmployeeCode    = EmployeeCode;
     bo.FirstName       = FirstName;
     bo.LastName        = LastName;
     bo.Sex             = Sex;
     bo.TelephoneNumber = TelephoneNumber;
     bo.MobileNumber    = MobileNumber;
     bo.Email           = Email;
     bo.CredentialsCode = CredentialsCode;
     bo.Birthday        = Birthday;
     bo.InquiryPassword = InquiryPassword;
 }
示例#4
0
文件: PersonVM.cs 项目: nongzhsh/Nccq
        public PersonVM(Person bo)
        {
            this.ID              = bo.ID;
            this.Name            = bo.Name;
            this.Description     = bo.Description;
            this.SortCode        = bo.SortCode;
            this.EmployeeCode    = bo.EmployeeCode;
            this.FirstName       = bo.FirstName;
            this.LastName        = bo.LastName;
            this.Sex             = bo.Sex;
            this.TelephoneNumber = bo.TelephoneNumber;
            this.MobileNumber    = bo.MobileNumber;
            this.Email           = bo.Email;
            this.CredentialsCode = bo.CredentialsCode;
            this.Birthday        = bo.Birthday;
            this.BirthdayString  = bo.Birthday.ToShortDateString();
            this.InquiryPassword = bo.InquiryPassword;

            if (bo.Sex)
            {
                this.SexString = "男";
            }
            else
                this.SexString = "女";

            this.SexSelector = new List<PlainFacadeItem>()
            {
                new PlainFacadeItem(){ ID = "true", Name = "男" },
                new PlainFacadeItem(){ ID = "false", Name = "女" }
            };

            if (bo.CredentialsType != null)
            {
                this.CredentialsTypeID = bo.CredentialsType.ID.ToString();
                this.CredentialsTypeItem = new PlainFacadeItem()
                {
                    ID = bo.CredentialsType.ID.ToString(),
                    Name = bo.CredentialsType.Name,
                    SortCode = bo.CredentialsType.SortCode
                };
            }
            if (bo.JobLevel != null)
            {
                this.JobLevelID = bo.JobLevel.ID.ToString();
                this.JobLevelItem = new PlainFacadeItem()
                {
                    ID = bo.JobLevel.ID.ToString(),
                    Name = bo.JobLevel.Name,
                    SortCode = bo.JobLevel.SortCode
                };
            }
            if (bo.JobTitle != null)
            {
                this.JobTitleID = bo.JobTitle.ID.ToString();
                this.JobTitleItem = new PlainFacadeItem()
                {
                    ID = bo.JobTitle.ID.ToString(),
                    Name = bo.JobTitle.Name,
                    SortCode = bo.JobTitle.SortCode
                };
            }
            if (bo.Department != null)
            {
                this.ParentItemID = bo.Department.ID.ToString();
                this.ParentItem = new SelfReferentialItem()
                {
                    ID = bo.ID.ToString(),
                    ParentID = bo.Department.ParentDapartment.ID.ToString(),
                    ItemName = bo.Name,
                    SortCode = bo.SortCode,
                    OperateName = "",
                    TargetType = "",
                    TipsString = ""
                };
            }
        }
示例#5
0
        public ActionResult Save(PersonVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo = new Person();
                    bo.ID = boVM.ID;
                }

                boVM.MapToBo(bo);

                var creID = Guid.Parse(boVM.CredentialsTypeID);
                var credentialType = _Service.GetSingleRelevance<CredentialsType>(creID);

                var jlID = Guid.Parse(boVM.JobLevelID);
                var jobLevel = _Service.GetSingleRelevance<JobLevel>(jlID);

                var jtID = Guid.Parse(boVM.JobTitleID);
                var jobTitle = _Service.GetSingleRelevance<JobTitle>(jtID);

                var dID = Guid.Parse(boVM.ParentItemID);
                var dept = _Service.GetSingleRelevance<Department>(dID);

                bo.Name = bo.FirstName + bo.LastName;
                if(String.IsNullOrEmpty(bo.SortCode))
                    bo.SortCode = BusinessEntityComponentsFactory.SortCodeByDefaultDateTime<Person>();

                bo.CredentialsType = credentialType;
                bo.JobLevel = jobLevel;
                bo.JobTitle = jobTitle;
                bo.Department = dept;
                bo.UpdateTime = DateTime.Now;
                bo.IsActivePerson = true;

                _Service.AddOrEditAndSave(bo);

                //var personInDepartment = _Service.GetSingleRelevanceBy<PersonsInDepartment>(p => p.Person.ID == bo.ID && p.Department.ID == dID);
                //if (personInDepartment == null)
                //{
                //    personInDepartment = new PersonsInDepartment() { Department = dept, Person = bo };
                //    _Service.AddAndSaveRelevance<PersonsInDepartment>(personInDepartment);
                //}

                var typeID = boVM.ParentItemID;
                return Json(PageComponentRepository<PersonVM>.SaveOK(true, "1", typeID));
            }
            else
            {
                var vItems = new List<ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                boVM.ParentItemColection = BusinessCollectionFactory<Department>.GetSelfReferentialItemCollection(true);
                boVM.CredentialsTypeCollection = BusinessCollectionFactory<CredentialsType>.GetPlainFacadeItemCollection();
                boVM.JobLevelCollection = BusinessCollectionFactory<JobLevel>.GetPlainFacadeItemCollection();
                boVM.JobTitleCollection = BusinessCollectionFactory<JobTitle>.GetPlainFacadeItemCollection();

                var editor = PageComponentRepository<PersonVM>.UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;

                return Json(editor);
            }
        }