Example #1
0
        public string CreateSharePetToken(int ownerId, string petCode, string toOwnerEmail)
        {
            var request = new PetShareCreateRequest {
                OwnerId = ownerId, PetCode = Guid.Parse(petCode), ToOwnerEmail = toOwnerEmail
            };

            return(_petServiceClient.CreateSharePetToken(request));
        }
Example #2
0
        public async Task <string> CreateSharePetAsync(PetShareCreateRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

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


            var token = await _petDataAccess.CreateSharePetAsync(request)
                        .ConfigureAwait(false);

            return(token);
        }
Example #3
0
        public async Task <string> CreateSharePetAsync(PetShareCreateRequest request)
        {
            long          records = 0;
            PetTableModel pet;
            var           token = Guid.NewGuid();

            using (var dbConnection = _dbConnectionFactory.Open())
            {
                using (var trans = dbConnection.OpenTransaction(IsolationLevel.ReadCommitted))
                {
                    if (request.PetId.HasValue)
                    {
                        pet = await dbConnection.SingleByIdAsync <PetTableModel>(request.PetId.Value)
                              .ConfigureAwait(false);
                    }
                    else
                    {
                        pet = await dbConnection.SingleAsync <PetTableModel>(x => x.Code == request.PetCode)
                              .ConfigureAwait(false);
                    }

                    var newtable = new OwnerSharedPetTableModel
                    {
                        OwnerTableModelId = request.OwnerId,
                        PetTableModelId   = pet.Id,
                        TokenCode         = token,
                        ToOwnerEmail      = request.ToOwnerEmail,
                        Used      = false,
                        CreatedOn = DateTime.Now
                    };

                    records = await dbConnection.InsertAsync <OwnerSharedPetTableModel>(newtable, selectIdentity : true)
                              .ConfigureAwait(false);

                    trans.Commit();
                }
            }

            return(token.ToString());
        }
Example #4
0
        public string CreateSharePetToken(PetShareCreateRequest request)
        {
            var response = _findMyPetClient.JsonClient().Post(request);

            return(response);
        }
Example #5
0
 public async Task <string> Post(PetShareCreateRequest request)
 {
     return(await _petProvider.CreateSharePetAsync(request)
            .ConfigureAwait(false));
 }