public async Task BecomeHuman(SocialInsurance info, string huid, CancellationToken cancellationToken = default(CancellationToken)) { if (!string.IsNullOrEmpty(info.IDCard)) { HumanInfo buildings = new HumanInfo() { Id = huid, //IsSocialInsurance = info.IsSocial, //SocialInsuranceInfo = info.IDCard, BecomeTime = info.EnTime, StaffStatus = StaffStatus.Regular }; Context.Attach(buildings); var entry = Context.Entry(buildings); //entry.Property(x => x.IsSocialInsurance).IsModified = true; //entry.Property(x => x.SocialInsuranceInfo).IsModified = true; entry.Property(x => x.BecomeTime).IsModified = true; entry.Property(x => x.StaffStatus).IsModified = true; if (Context.SocialInsurances.Any(x => x.IDCard == info.IDCard)) { Context.Attach(info); Context.Update(info); } else { Context.Add(info); } await Context.SaveChangesAsync(cancellationToken); } else { throw new ArgumentNullException("have no IDCard"); } }
public async Task <ModifyInfo> UpdateExamineStatus(string modifyId, ExamineStatusEnum status, CancellationToken cancellationToken = default(CancellationToken)) { var modify = await GetModifyAsync(a => a.Where(b => b.ID == modifyId)); if (modify != null) { switch (modify.Type) { case CreateHumanModifyType: { HumanInfo buildings = new HumanInfo() { Id = modify.Ext1, StaffStatus = StaffStatus.Entry }; Context.Attach(buildings); var entry = Context.Entry(buildings); entry.Property(x => x.StaffStatus).IsModified = true; } break; case BecomeHumanModifyType: { SocialInsurance responinfo = JsonHelper.ToObject <SocialInsurance>(modify.Ext2); await BecomeHuman(responinfo, modify.Ext1, cancellationToken); } break; case ChangeHumanModifyType: { ChangeInfo responinfo = JsonHelper.ToObject <ChangeInfo>(modify.Ext2); await ChangeHuman(responinfo, modify.Ext1, cancellationToken); } break; case LeaveHumanModifyType: { LeaveInfo responinfo = JsonHelper.ToObject <LeaveInfo>(modify.Ext2); await LeaveHuman(responinfo, modify.Ext1, cancellationToken); } break; default: break; } ///////////////////// ModifyInfo mbuildings = new ModifyInfo() { ID = modifyId, ExamineTime = DateTime.Now, ExamineStatus = status, }; Context.Attach(mbuildings); var mentry = Context.Entry(mbuildings); mentry.Property(x => x.ExamineStatus).IsModified = true; mentry.Property(x => x.ExamineTime).IsModified = true; await Context.SaveChangesAsync(cancellationToken); } return(modify); }