Example #1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <returns></returns>
        public async Task <HumanInfoLeave> UpdateAsync(UserInfo user, HumanInfoLeave humanInfoLeave, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (humanInfoLeave == null)
            {
                throw new ArgumentNullException(nameof(humanInfoLeave));
            }
            var old = HumanInfoLeaves.Where(a => a.Id == humanInfoLeave.Id).SingleOrDefault();

            if (old == null)
            {
                throw new Exception("更新的对象不存在");
            }
            old.IsProcedure = humanInfoLeave.IsProcedure;
            old.LeaveTime   = humanInfoLeave.LeaveTime;
            old.NewHumanId  = humanInfoLeave.NewHumanId;
            old.UpdateTime  = DateTime.Now;
            old.UpdateUser  = user.Id;
            Context.Update(old);
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateException) { throw; }
            return(humanInfoLeave);
        }
Example #2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns></returns>
        public async Task DeleteAsync(UserInfo user, HumanInfoLeave humanInfoLeave, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (humanInfoLeave == null)
            {
                throw new ArgumentNullException(nameof(humanInfoLeave));
            }
            humanInfoLeave.DeleteTime = DateTime.Now;
            humanInfoLeave.DeleteUser = user.Id;
            humanInfoLeave.IsDeleted  = true;
            Context.Attach(humanInfoLeave);
            var entry = Context.Entry(humanInfoLeave);

            entry.Property(x => x.IsDeleted).IsModified  = true;
            entry.Property(x => x.DeleteUser).IsModified = true;
            entry.Property(x => x.DeleteTime).IsModified = true;
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateException)
            {
                throw;
            }
        }
Example #3
0
        /// <summary>
        /// 更新人事审核状态
        /// </summary>
        /// <param name="humanId"></param>
        /// <param name="status"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task UpdateExamineStatus(string id, ExamineStatusEnum status, CancellationToken cancellationToken = default(CancellationToken))
        {
            HumanInfoLeave humanInfoLeave = new HumanInfoLeave()
            {
                Id            = id,
                UpdateTime    = DateTime.Now,
                ExamineStatus = status
            };

            Context.Attach(humanInfoLeave);
            var entry = Context.Entry(humanInfoLeave);

            entry.Property(x => x.ExamineStatus).IsModified = true;
            entry.Property(x => x.UpdateTime).IsModified    = true;
            try
            {
                await Context.SaveChangesAsync(cancellationToken);
            }
            catch (DbUpdateException) { throw; }
        }
Example #4
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <returns></returns>
 public async Task <HumanInfoLeave> CreateAsync(UserInfo user, HumanInfoLeave humanInfoLeave, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (humanInfoLeave == null)
     {
         throw new ArgumentNullException(nameof(humanInfoLeave));
     }
     if (string.IsNullOrEmpty(humanInfoLeave.Id))
     {
         humanInfoLeave.Id = Guid.NewGuid().ToString();
     }
     humanInfoLeave.CreateTime = DateTime.Now;
     humanInfoLeave.CreateUser = user.Id;
     humanInfoLeave.IsDeleted  = false;
     Context.Add(humanInfoLeave);
     try
     {
         await Context.SaveChangesAsync(cancellationToken);
     }
     catch (DbUpdateException) { throw; }
     return(humanInfoLeave);
 }