示例#1
0
        /// <summary>
        /// Get user aggregate root by identity.
        /// </summary>
        /// <param name="id">user identity</param>
        /// <returns></returns>
        public override User Get(UserId id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }

            var user = _userStorage.Get(id);

            return(user == null
                       ? null
                       : new User(
                       new UserId(user.Id),
                       user.FirstName,
                       user.LastName,
                       user.Email,
                       user.Password,
                       user.Image,
                       user.Phone,
                       user.DateOfBirth,
                       user.Roles.ToList(),
                       user.Mood == null ? null : new UserMood(user.Mood.Date, user.Mood.Rate),
                       user.IsDeleted));
        }
        public int Authorize(AuthVM authVM)
        {
            var user = _userStorage.Get(authVM.Login, authVM.Password);

            return(user.UserId);
        }