Ejemplo n.º 1
0
        /// <summary>
        ///     Get User by Id
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        //public User GetUser(string userId)
        //{
        //    _logger.LogInformation($"BEGIN GetUser");
        //    try
        //    {
        //        var user = _userRepository.GetUser(userId);
        //        if (user == null) return null;
        //        var result = new User
        //        {
        //            AppId = user.AppId,
        //            Email = user.Email,
        //            FacebookInfo = user.FacebookInfo,
        //            GoogleInfo = user.GoogleInfo,
        //            Id = user.Id,
        //            Name = user.Name,
        //            TwitterInfo = user.TwitterInfo
        //        };
        //        return result;
        //    }
        //    catch (Exception ex)
        //    {
        //        _logger.LogError($"Exception on GetUser with message: {ex.Message}");
        //        return null;
        //    }
        //}

        /// <summary>
        ///     Get Alias information by id (including associated Product)
        /// </summary>
        /// <param name="aliasId"></param>
        /// <returns></returns>
        public Alias GetAlias(int aliasId)
        {
            _logger.LogInformation($"BEGIN GetAlias");
            try
            {
                var alias = _aliasRepository.GetAlias(aliasId);

                if (alias == null)
                {
                    return(null);
                }

                var result = new Alias
                {
                    Id          = alias.AliasId,
                    Modified    = alias.Alias.Modified,
                    Name        = alias.Name,
                    VirtualName = alias.Name.RemoveDiacritics(),
                };
                return(result);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Exception on GetAlias with message: {ex.Message}");
                return(null);
            }
        }
Ejemplo n.º 2
0
        private IEnumerable <Alias> MapAliases(IEnumerable <AliasMultilingual> aliases)
        {
            var collection = new List <Alias>();

            foreach (var alias in aliases.ToList())
            {
                var result = new Alias
                {
                    Id          = alias.AliasId,
                    Modified    = alias.Alias.Modified,
                    Name        = alias.Name,
                    VirtualName = alias.Name.RemoveDiacritics(),
                };
                collection.Add(result);
            }

            return(collection.Count == 0 ? null : collection);
        }