Ejemplo n.º 1
0
        public object Get(AddressHistoryRequest request)
        {
            var accountId = new Guid(this.GetSession().UserAuthId);

            var addresses = _dao.FindHistoricByAccountId(accountId);

            var historyAddresses = from address in addresses
                                   select new Address()
            {
                Id           = address.Id,
                FriendlyName = address.FriendlyName,
                StreetNumber = address.StreetNumber,
                Street       = address.Street,
                City         = address.City,
                ZipCode      = address.ZipCode,
                State        = address.State,
                FullAddress  = address.FullAddress,
                Longitude    = address.Longitude,
                Latitude     = address.Latitude,
                Apartment    = address.Apartment,
                RingCode     = address.RingCode,
                BuildingName = address.BuildingName,
                IsHistoric   = address.IsHistoric
            };

            var historyAddressesDistinct = from address in historyAddresses
                                           group address by new { address.DisplayLine1, address.DisplayLine2 } into addressesDist
            select addressesDist.First();

            return(historyAddressesDistinct.Take(MaximumNumberEntriesInHistoryAddressList).ToArray());
        }
Ejemplo n.º 2
0
        public object Delete(AddressHistoryRequest request)
        {
            var address = _dao.FindById(request.AddressId);

            var account = _accountDao.FindById(new Guid(this.GetSession().UserAuthId));

            if (account.Id != address.AccountId)
            {
                throw new HttpError(HttpStatusCode.Unauthorized, "Can't remove another account's address");
            }

            _commandBus.Send(new RemoveAddressFromHistory {
                AddressId = request.AddressId, AccountId = account.Id
            });

            return(new HttpResult(HttpStatusCode.OK));
        }