AuditLogViewModel Map(AuditLog alog) { //return new AuditLogViewModel //{ // id=alog.Id, // actionName=alog.Action, // moduleName=alog.Module,k // timeStamp=alog.ActionTimeStamp, // CostCentreId=alog.ActionOwner==null?0: alog.ActionOwner.Id, // UserId=alog.ActionUser==null?0: alog.ActionUser.Id, // CostCentreName=_costCentreRepository.GetById(alog.ActionOwner.Id).Name, // UserName=_userRepository.GetById(alog.ActionUser.Id).Username //}; AuditLogViewModel aLogViewModel = new AuditLogViewModel(); { aLogViewModel.id=alog.Id; aLogViewModel.actionName=alog.Action; aLogViewModel.moduleName=alog.Module; aLogViewModel.timeStamp=alog.ActionTimeStamp; aLogViewModel.CostCentreId = alog.ActionOwner == null ? Guid .Empty: alog.ActionOwner.Id; aLogViewModel.UserId = alog.ActionUser == null ? Guid.Empty: alog.ActionUser.Id; if (alog.ActionOwner != null) aLogViewModel.CostCentreName = _costCentreRepository.GetById(alog.ActionOwner.Id).Name; if (alog.ActionUser != null) aLogViewModel.UserName = _userRepository.GetById(alog.ActionUser.Id).Username; } return aLogViewModel; }
public AuditLogViewModel GetById(Guid id) { AuditLog aL = new AuditLog(Guid.Empty); if (id != null) aL = _auditLogRepository.GetById(id); return Map(aL); }