public async Task <PetAlert> FoundPetAsync(PetAlertFoundRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (!request.PetId.HasValue && !request.PetCode.HasValue)
            {
                throw new ArgumentException("Id and Code are NULL");
            }

            PetTableModel pet = null;

            if (request.PetId.HasValue)
            {
                pet = await _petDataAccess.GetPetByIdAsync(request.PetId.Value)
                      .ConfigureAwait(false);
            }
            else if (request.PetCode.HasValue)
            {
                pet = await _petDataAccess.GetPetByCodeAsync(request.PetCode.Value)
                      .ConfigureAwait(false);
            }

            var petAlertId = await _petAlertDataAccess.FoundPet(pet.Id, request.Comment, request.MakeItPublic)
                             .ConfigureAwait(false);

            var petAlert = await _petAlertDataAccess.GetPetAlertByIdAsync(petAlertId)
                           .ConfigureAwait(false);

            return(_petAlertMapper.MapPetAlertTableToPetAlert(petAlert));
        }
        public async Task <PetAlert> Put(PetAlertFoundRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return(await _petAlertProvider.FoundPetAsync(request)
                   .ConfigureAwait(false));
        }
Beispiel #3
0
        public PetAlert FoundPet(PetAlertViewModel model)
        {
            var request = new PetAlertFoundRequest
            {
                OwnerId      = model.OwnerId,
                PetCode      = Guid.Parse(model.PetCode),
                Comment      = HttpUtility.HtmlEncode(model.Commets),
                MakeItPublic = model.MakeItPublic
            };

            var response = _findMyPetClient.JsonClient().Put(request);

            return(response);
        }