public async Task <bool> UpdateAsync(BaseLog updated) { var cuser = await GetCurrentUser(); if (cuser != null) { var uid = cuser.Id; var logs = from log in _context.JobLogs where log.ApplicationUser.Id == uid where log.Id == updated.Id select log; if (logs.Count() > 0) { var exist = logs.First(); Type DestType = exist.GetType(); Type SrcType = updated.GetType(); if (SrcType == DestType) { foreach (var prop in SrcType.GetProperties()) { if (prop.Name != "ApplicationUser") { prop.SetValue(exist, prop.GetValue(updated, null), null); } } await _userManager.UpdateAsync(cuser); return(true); } } } return(false); }
public async Task <bool> AddAsync(BaseLog log) { var cuser = await GetCurrentUser(); if (cuser != null) { if (cuser.JobLogs == null) { cuser.JobLogs = new List <BaseLog>(); } var logs = cuser.JobLogs; logs.Add(log); await _userManager.UpdateAsync(cuser); return(true); } return(false); }