Blog.Logic.Core.AddressLogic.GetByUser C# (CSharp) Method

GetByUser() public method

public GetByUser ( int userId ) : Address
userId int
return Blog.Common.Contracts.Address
        public Address GetByUser(int userId)
        {
            try
            {
                var db = _addressRepository.Find(a => a.UserId == userId, true).FirstOrDefault();

                if (db != null)
                {
                    return AddressMapper.ToDto(db);
                }

                return new Address().GenerateError<Address>(
                    (int) Constants.Error.RecordNotFound,
                    string.Format("No address found for user with Id {0}", userId));
            }
            catch (Exception ex)
            {
                throw new BlogException(ex.Message, ex.InnerException);
            }
        }