public string SaveChanges(string jsonString) { try { JsonSerializerSettings st = new JsonSerializerSettings(); st.DateTimeZoneHandling = DateTimeZoneHandling.Local; HRInfoEntity entity = JsonConvert.DeserializeObject <HRInfoEntity>(jsonString, st); HRInfoManager service = new HRInfoManager(); if (entity.iGuid == "") { if (service.GetUniqueFirstOrDefault(entity.iItemName, entity.iCompany, entity.iEmpNo, entity.iIdCard) != null) { return("已存在相同记录!"); } entity.iCreatedBy = SessionHelper.CurrentUser.UserName; entity.iUpdatedBy = SessionHelper.CurrentUser.UserName; service.Insert(entity); } else { entity.iUpdatedBy = SessionHelper.CurrentUser.UserName; service.Update(entity); } return("success"); } catch (Exception e) { return(e.ToString()); } }
private void MergeToDBWithLog(List <HRInfoEntity> list) { HRInfoManager service = new HRInfoManager(); foreach (var item in list) { if (string.IsNullOrEmpty(item.iGuid)) { item.iCreatedBy = SessionHelper.CurrentUser.UserName; item.iUpdatedBy = SessionHelper.CurrentUser.UserName; service.Insert(item); } else { item.iUpdatedBy = SessionHelper.CurrentUser.UserName; service.Update(item); } } }