Esempio n. 1
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <returns></returns>
        public async Task <HumanInfo> UpdateAsync(UserInfo user, HumanInfo humanInfo, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (humanInfo == null)
            {
                throw new ArgumentNullException(nameof(humanInfo));
            }
            var old = HumanInfos.Where(a => a.Id == humanInfo.Id).SingleOrDefault();

            if (old == null)
            {
                throw new Exception("更新的对象不存在");
            }
            old.BankAccount           = humanInfo.BankAccount;
            old.BankName              = humanInfo.BankName;
            old.DepartmentId          = humanInfo.DepartmentId;
            old.EmailAddress          = humanInfo.EmailAddress;
            old.Desc                  = humanInfo.Desc;
            old.PositionType          = humanInfo.PositionType;
            old.EmergencyContact      = humanInfo.EmergencyContact;
            old.EmergencyContactPhone = humanInfo.EmergencyContactPhone;
            old.EmergencyContactType  = humanInfo.EmergencyContactType;
            old.EntryTime             = humanInfo.EntryTime;
            old.MaritalStatus         = humanInfo.MaritalStatus;
            old.HighestEducation      = humanInfo.HighestEducation;
            old.HealthCondition       = humanInfo.HealthCondition;
            old.DomicilePlace         = humanInfo.DomicilePlace;
            old.HouseholdType         = humanInfo.HouseholdType;
            old.IDCard                = humanInfo.IDCard;
            old.FamilyAddress         = humanInfo.FamilyAddress;
            old.LeaveTime             = humanInfo.LeaveTime;
            old.BecomeTime            = humanInfo.BecomeTime;
            old.Name                  = humanInfo.Name;
            old.NativePlace           = humanInfo.NativePlace;
            old.Nationality           = humanInfo.Nationality;
            old.Picture               = humanInfo.Picture;
            old.Phone                 = humanInfo.Phone;
            old.Position              = humanInfo.Position;
            old.PolicitalStatus       = humanInfo.PolicitalStatus;
            old.Sex         = humanInfo.Sex;
            old.UserID      = humanInfo.UserID;
            old.UpdateTime  = DateTime.Now;
            old.UpdateUser  = user.Id;
            old.StaffStatus = humanInfo.StaffStatus;
            old.Company     = humanInfo.Company;

            old.AdministrativeBack = humanInfo.AdministrativeBack;
            old.ClothesBack        = humanInfo.ClothesBack;
            old.Modify             = humanInfo.Modify;
            old.OtherBack          = humanInfo.OtherBack;
            old.PortBack           = humanInfo.PortBack;
            old.RecentModify       = humanInfo.RecentModify;
            Context.Update(old);
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateException) { throw; }
            return(humanInfo);
        }
Esempio n. 2
0
 /// <summary>
 /// 查询列表
 /// </summary>
 /// <returns></returns>
 public Task <List <TResult> > ListAsync <TResult>(Func <IQueryable <HumanInfo>, IQueryable <TResult> > query, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (query == null)
     {
         throw new ArgumentNullException(nameof(query));
     }
     return(query.Invoke(HumanInfos.AsNoTracking()).ToListAsync(cancellationToken));
 }