public User UpdateUser(User user) { var dbUser = _unitOfWork.Users.GetById(user.Id); if (dbUser == null) throw new DataException(string.Format("User with id {0} could not be found.", user.Id)); dbUser.IsActive = user.IsActive; dbUser.UserName = user.UserName; dbUser.Roles.Clear(); foreach (var dbRole in user.Roles.Select(role => _unitOfWork.Roles.GetById(role.Id))) { dbUser.Roles.Add(dbRole); } dbUser = _unitOfWork.Users.Update(dbUser); _unitOfWork.Commit(); return dbUser.ToModel(); }
public Session(int id, Guid sessionId, User user) : base(id) { SessionId = sessionId; User = user; }