public async Task <Guid> Handle(CreateAddressRequest request, CancellationToken cancellationToken)
        {
            var entry = AddressBookEntry.Create(request.Line1, request.Line2, request.City, request.State,
                                                request.PostalCode);

            _repo.Add(entry);
            return(await Task.FromResult(entry.Id));
        }
        public async Task <ActionResult> OnGet(Guid id)
        {
            Specification <AddressBookEntry> spec = new EntryByIdSpecification(id);
            AddressBookEntry temp = _repo.Find(spec)[0];

            _repo.Remove(temp);
            return(RedirectToPage("Index"));
        }
        Task <Unit> IRequestHandler <UpdateAddressRequest, Unit> .Handle(UpdateAddressRequest request, CancellationToken cancellationToken)
        {
            Specification <AddressBookEntry> spec = new EntryByIdSpecification(request.Id);
            AddressBookEntry temp = _repo.Find(spec)[0];

            temp.Update(request.Line1, request.Line2, request.City, request.State, request.PostalCode);
            _repo.Update(temp);
            return(Task.FromResult(Unit.Value));
        }
예제 #4
0
        public async void OnGet(Guid id)
        {
            Specification <AddressBookEntry> spec = new EntryByIdSpecification(id);
            AddressBookEntry temp = _repo.Find(spec)[0];

            UpdateAddressRequest            = new UpdateAddressRequest();
            UpdateAddressRequest.Id         = temp.Id;
            UpdateAddressRequest.Line1      = temp.Line1;
            UpdateAddressRequest.Line2      = temp.Line2;
            UpdateAddressRequest.City       = temp.City;
            UpdateAddressRequest.State      = temp.State;
            UpdateAddressRequest.PostalCode = temp.PostalCode;
            _ = await _mediator.Send(UpdateAddressRequest);
        }