public bool AddAddress(AddressDto dto)
        {
            if (!this.db.Addresses.Any(x => x.DeletedOn.HasValue == false && x.Name.Trim() == dto.Name.Trim()))
            {
                this.db.Addresses.Add(new Address
                {
                    Name = dto.Name,
                    AddressText = dto.AddressText,
                    District = dto.District,
                    CountyId = dto.County.Id,
                    CityId = dto.City.Id,
                    PostalCode = dto.PostalCode,
                    Coordinates = dto.Coordinates,
                    PersonName = dto.PersonName,
                    PrimaryPhone = dto.PrimaryPhone,
                    CompanyName = dto.CompanyName,
                    TaxNumber = dto.TaxNumber,
                    TaxOffice = dto.TaxOffice,
                    IsApproved = dto.IsApproved,
                    IsCompany = dto.IsCompany,
                    UserId = dto.User.Id,
                    UpdatedOn = DateTime.Now,
                    CreatedOn = DateTime.Now,
                    UpdatedBy = dto.UpdatedBy,
                    Comment = dto.Comment
                });
                this.db.SaveChanges();

                return true;
            }
            return false;
        }
        /// <summary>
        /// The add address.
        /// </summary>
        /// <param name="dto">
        /// The dto.
        /// </param>
        /// <returns>
        /// The System.Boolean.
        /// </returns>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public int AddAddress(AddressDto dto)
        {
            if (!this.db.Addresses.Any(x => x.DeletedOn.HasValue == false && x.UserId == dto.User.Id && x.Name.Trim() == dto.Name.Trim()))
            {
                this.db.Addresses.Add(new Address
                    {
                        Name = dto.Name.Trim(),
                        AddressText = dto.AddressText.Trim(),
                        AddressType = dto.AddressType.Trim(),
                        //District = dto.District.Trim(),
                        CountyId = dto.County.Id,
                        CityId = dto.City.Id,
                        PostalCode = dto.PostalCode.Trim(),
                        PersonName = dto.PersonName.Trim(),
                        PrimaryPhone = dto.PrimaryPhone.Trim(),
                        CompanyName = dto.CompanyName.Trim(),
                        TaxNumber = dto.TaxNumber.Trim(),
                        TaxOffice = dto.TaxOffice.Trim(),
                        IsApproved = dto.IsApproved,
                        IsCompany = dto.IsCompany,
                        UserId = dto.User.Id,
                        UpdatedOn = DateTime.Now,
                        CreatedOn = DateTime.Now,
                        UpdatedBy = dto.UpdatedBy,
                        Comment = dto.Comment
                    });
                this.db.SaveChanges();

                var topAddress = this.db.Addresses.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Name == dto.Name.Trim() && x.UserId == dto.User.Id);
                return topAddress.Id;
            }

            return 0;
        }
 public bool AddAddress(AddressDto dto)
 {
     throw new NotImplementedException();
 }
        public bool UpdateAddress(AddressDto dto)
        {
            var address = this.db.Addresses.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.UserId == dto.User.Id && x.Id == dto.Id);

            if (address != null)
            {
                address.Name = dto.Name.Trim();
                address.AddressText = dto.AddressText.Trim();
                address.AddressType = dto.AddressType.Trim();
                address.CountyId = dto.County.Id;
                address.CityId = dto.City.Id;
                address.PostalCode = dto.PostalCode.Trim();
                address.PersonName = dto.PersonName.Trim();
                address.PrimaryPhone = dto.PrimaryPhone.Trim();
                address.CompanyName = dto.CompanyName.Trim();
                address.TaxNumber = dto.TaxNumber.Trim();
                address.TaxOffice = dto.TaxOffice.Trim();
                address.IsApproved = dto.IsApproved;
                address.IsCompany = dto.IsCompany;
                address.UpdatedOn = DateTime.Now;
                address.UpdatedBy = dto.UpdatedBy;
                address.Comment = dto.Comment;

                this.db.SaveChanges();

                return true;
            }

            return false;
        }
        public bool DeleteAddress(AddressDto dto)
        {
            var address = this.db.Addresses.FirstOrDefault(x => x.DeletedOn.HasValue == false && x.Id == dto.Id);
            if (address != null)
            {
                address.DeletedOn = DateTime.Now;
                address.UpdatedBy = dto.UpdatedBy;

                this.db.SaveChanges();

                return true;
            }

            return false;
        }