コード例 #1
0
 public async Task AddAddress(Address_OG address)
 {
     try
     {
         await _context.Addresses.InsertOneAsync(address);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
        public async Task <bool> DeleteAddress(Address_OG address)
        {
            try
            {
                DeleteResult actionResult
                    = await _context.Addresses
                      .DeleteOneAsync(n => n.Id.Equals(address.Id));

                return(actionResult.IsAcknowledged &&
                       actionResult.DeletedCount > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public async Task <bool> UpdateAddress(Address_OG address)
        {
            try
            {
                ReplaceOneResult actionResult
                    = await _context.Addresses
                      .ReplaceOneAsync(n => n.Id.Equals(address.Id)
                                       , address
                                       , new UpdateOptions { IsUpsert = true });

                return(actionResult.IsAcknowledged &&
                       actionResult.ModifiedCount > 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }